本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/models.ServiceInstance.ServicePlan方法的典型用法代码示例。如果您正苦于以下问题:Golang ServiceInstance.ServicePlan方法的具体用法?Golang ServiceInstance.ServicePlan怎么用?Golang ServiceInstance.ServicePlan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/models.ServiceInstance
的用法示例。
在下文中一共展示了ServiceInstance.ServicePlan方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.LastOperation.Type = instanceSummary.LastOperation.Type
instance.LastOperation.State = instanceSummary.LastOperation.State
instance.LastOperation.Description = instanceSummary.LastOperation.Description
instance.ApplicationNames = applicationNames
instance.ServicePlan = servicePlan
instance.ServiceOffering = serviceOffering
instances = append(instances, instance)
}
return
}
示例2:
Expect(serviceRepo.UpdateCallCount()).To(Equal(0))
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"JSON is invalid"},
))
})
})
Context("when the service with the given name is not user provided", func() {
BeforeEach(func() {
plan := models.ServicePlanFields{Guid: "my-plan-guid"}
serviceInstance := models.ServiceInstance{}
serviceInstance.Name = "found-service-name"
serviceInstance.ServicePlan = plan
requirementsFactory.ServiceInstance = serviceInstance
})
It("fails and tells the user what went wrong", func() {
runCommand("-p", `{"foo":"bar"}`, "service-name")
Expect(serviceRepo.UpdateCallCount()).To(Equal(0))
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"Service Instance is not user provided"},
))
})
})
示例3:
Expect(runCommand("okay-this-time-please??")).To(BeFalse())
})
})
Describe("After Requirement", func() {
createServiceInstanceWithState := func(state string) {
offering := models.ServiceOfferingFields{Label: "mysql", DocumentationUrl: "http://documentation.url", Description: "the-description"}
plan := models.ServicePlanFields{Guid: "plan-guid", Name: "plan-name"}
serviceInstance := models.ServiceInstance{}
serviceInstance.Name = "service1"
serviceInstance.Guid = "service1-guid"
serviceInstance.LastOperation.Type = "create"
serviceInstance.LastOperation.State = "in progress"
serviceInstance.LastOperation.Description = "creating resource - step 1"
serviceInstance.ServicePlan = plan
serviceInstance.ServiceOffering = offering
serviceInstance.DashboardUrl = "some-url"
serviceInstance.LastOperation.State = state
serviceInstance.LastOperation.CreatedAt = "created-date"
serviceInstance.LastOperation.UpdatedAt = "updated-date"
requirementsFactory.ServiceInstance = serviceInstance
}
createServiceInstance := func() {
createServiceInstanceWithState("")
}
Describe("when invoked by a plugin", func() {
var (
pluginModel *plugin_models.GetService_Model
示例4:
Context("when the service is not user provided", func() {
BeforeEach(func() {
setupTestServer(apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "PUT",
Path: "/v2/service_instances/my-service-instance-guid?accepts_incomplete=true",
Matcher: testnet.RequestBodyMatcher(`{"name":"new-name"}`),
Response: testnet.TestResponse{Status: http.StatusCreated},
}))
})
It("renames the service", func() {
serviceInstance := models.ServiceInstance{}
serviceInstance.GUID = "my-service-instance-guid"
serviceInstance.ServicePlan = models.ServicePlanFields{
GUID: "some-plan-guid",
}
err := repo.RenameService(serviceInstance, "new-name")
Expect(testHandler).To(HaveAllRequestsCalled())
Expect(err).NotTo(HaveOccurred())
})
})
Context("when the service is user provided", func() {
BeforeEach(func() {
setupTestServer(apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "PUT",
Path: "/v2/user_provided_service_instances/my-service-instance-guid",
Matcher: testnet.RequestBodyMatcher(`{"name":"new-name"}`),
Response: testnet.TestResponse{Status: http.StatusCreated},
示例5:
})
Context("when the route can be found", func() {
BeforeEach(func() {
routeRepo.FindReturns(models.Route{Guid: "route-guid"}, nil)
})
Context("when the service instance is not user-provided and requires route forwarding", func() {
BeforeEach(func() {
serviceInstance := models.ServiceInstance{
ServiceOffering: models.ServiceOfferingFields{
Requires: []string{"route_forwarding"},
},
}
serviceInstance.ServicePlan = models.ServicePlanFields{
Guid: "service-plan-guid",
}
serviceInstanceRequirement.GetServiceInstanceReturns(serviceInstance)
})
It("asks the user to confirm", func() {
ui.Inputs = []string{"n"}
cmd.Execute(flagContext)
Expect(ui.Prompts).To(ContainSubstrings(
[]string{"Binding may cause requests for route", "Do you want to proceed?"},
))
})
Context("when the user confirms", func() {
JustBeforeEach(func() {
defer func() { recover() }()