本文整理匯總了Golang中cf/models.ServicePlanFields類的典型用法代碼示例。如果您正苦於以下問題:Golang ServicePlanFields類的具體用法?Golang ServicePlanFields怎麽用?Golang ServicePlanFields使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ServicePlanFields類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ToModels
func (resource ServiceInstancesSummaries) ToModels() (instances []models.ServiceInstance) {
for _, instanceSummary := range resource.ServiceInstances {
applicationNames := resource.findApplicationNamesForInstance(instanceSummary.Name)
planSummary := instanceSummary.ServicePlan
servicePlan := models.ServicePlanFields{}
servicePlan.Name = planSummary.Name
servicePlan.Guid = planSummary.Guid
offeringSummary := planSummary.ServiceOffering
serviceOffering := models.ServiceOfferingFields{}
serviceOffering.Label = offeringSummary.Label
serviceOffering.Provider = offeringSummary.Provider
serviceOffering.Version = offeringSummary.Version
instance := models.ServiceInstance{}
instance.Name = instanceSummary.Name
instance.ApplicationNames = applicationNames
instance.ServicePlan = servicePlan
instance.ServiceOffering = serviceOffering
instances = append(instances, instance)
}
return
}
示例2: ToModel
func (resource ServiceOfferingResource) ToModel() (offering models.ServiceOffering) {
offering.ServiceOfferingFields = resource.ToFields()
for _, p := range resource.Entity.ServicePlans {
servicePlan := models.ServicePlanFields{}
servicePlan.Name = p.Entity.Name
servicePlan.Guid = p.Metadata.Guid
offering.Plans = append(offering.Plans, servicePlan)
}
return offering
}
示例3:
ctxt := testcmd.NewContext("create-service", args)
config := testconfig.NewRepositoryWithDefaults()
cmd := NewCreateService(fakeUI, config, serviceRepo)
reqFactory := &testreq.FakeReqFactory{}
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
var _ = Describe("create-service command", func() {
It("successfully creates a service", func() {
offering := models.ServiceOffering{}
offering.Label = "cleardb"
plan := models.ServicePlanFields{}
plan.Name = "spark"
plan.Guid = "cleardb-spark-guid"
offering.Plans = []models.ServicePlanFields{plan}
offering2 := models.ServiceOffering{}
offering2.Label = "postgres"
serviceRepo := &testapi.FakeServiceRepo{}
serviceRepo.FindServiceOfferingsForSpaceByLabelReturns.ServiceOfferings = []models.ServiceOffering{
offering,
offering2,
}
ui := callCreateService([]string{"cleardb", "spark", "my-cleardb-service"},
[]string{},
serviceRepo,
示例4:
}
userProvidedServiceInstanceRepo := &testapi.FakeUserProvidedServiceInstanceRepo{}
ui := callUpdateUserProvidedService(args, reqFactory, userProvidedServiceInstanceRepo)
Expect(userProvidedServiceInstanceRepo.UpdateServiceInstance).NotTo(Equal(serviceInstance))
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"FAILED"},
{"JSON is invalid"},
})
})
It("TestUpdateUserProvidedServiceWithAServiceInstanceThatIsNotUserProvided", func() {
args := []string{"-p", `{"foo":"bar"}`, "service-name"}
plan := models.ServicePlanFields{}
plan.Guid = "my-plan-guid"
serviceInstance := models.ServiceInstance{}
serviceInstance.Name = "found-service-name"
serviceInstance.ServicePlan = plan
reqFactory := &testreq.FakeReqFactory{
LoginSuccess: true,
ServiceInstance: serviceInstance,
}
userProvidedServiceInstanceRepo := &testapi.FakeUserProvidedServiceInstanceRepo{}
ui := callUpdateUserProvidedService(args, reqFactory, userProvidedServiceInstanceRepo)
Expect(userProvidedServiceInstanceRepo.UpdateServiceInstance).NotTo(Equal(serviceInstance))
示例5:
binding2.Url = "/v2/service_bindings/service-binding-2-guid"
binding2.AppGuid = "app-2-guid"
serviceInstance.ServiceBindings = []models.ServiceBindingFields{binding, binding2}
apiErr := repo.DeleteService(serviceInstance)
Expect(apiErr).NotTo(BeNil())
Expect(apiErr.Error()).To(Equal("Cannot delete service instance, apps are still bound to it"))
})
It("TestRenameService", func() {
path := "/v2/service_instances/my-service-instance-guid"
serviceInstance := models.ServiceInstance{}
serviceInstance.Guid = "my-service-instance-guid"
plan := models.ServicePlanFields{}
plan.Guid = "some-plan-guid"
serviceInstance.ServicePlan = plan
testRenameService(path, serviceInstance)
})
It("TestRenameServiceWhenServiceIsUserProvided", func() {
path := "/v2/user_provided_service_instances/my-service-instance-guid"
serviceInstance := models.ServiceInstance{}
serviceInstance.Guid = "my-service-instance-guid"
testRenameService(path, serviceInstance)
})
It("finds service offerings by label and provider", func() {
testServer, _, repo := createServiceRepo([]testnet.TestRequest{{
示例6:
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
ui := callShowService([]string{}, reqFactory)
Expect(ui.FailedWithUsage).To(BeTrue())
ui = callShowService([]string{"my-service"}, reqFactory)
Expect(ui.FailedWithUsage).To(BeFalse())
})
It("TestShowServiceOutput", func() {
offering := models.ServiceOfferingFields{}
offering.Label = "mysql"
offering.DocumentationUrl = "http://documentation.url"
offering.Description = "the-description"
plan := models.ServicePlanFields{}
plan.Guid = "plan-guid"
plan.Name = "plan-name"
serviceInstance := models.ServiceInstance{}
serviceInstance.Name = "service1"
serviceInstance.Guid = "service1-guid"
serviceInstance.ServicePlan = plan
serviceInstance.ServiceOffering = offering
reqFactory := &testreq.FakeReqFactory{
LoginSuccess: true,
TargetedSpaceSuccess: true,
ServiceInstance: serviceInstance,
}
ui := callShowService([]string{"service1"}, reqFactory)