当前位置: 首页>>代码示例>>Golang>>正文


Golang ServiceInstance.ServicePlan方法代码示例

本文整理汇总了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
}
开发者ID:yingkitw,项目名称:cli,代码行数:29,代码来源:service_summary.go

示例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"},
				))
			})
		})
开发者ID:sunatthegilddotcom,项目名称:cli,代码行数:30,代码来源:update_user_provided_service_test.go

示例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
开发者ID:xinpingluo,项目名称:cli,代码行数:31,代码来源:service_test.go

示例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},
开发者ID:Reejoshi,项目名称:cli,代码行数:31,代码来源:services_test.go

示例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() }()
开发者ID:sunatthegilddotcom,项目名称:cli,代码行数:31,代码来源:bind_route_service_test.go


注:本文中的github.com/cloudfoundry/cli/cf/models.ServiceInstance.ServicePlan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。