當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ServicePlanFields.Name方法代碼示例

本文整理匯總了Golang中cf/models.ServicePlanFields.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServicePlanFields.Name方法的具體用法?Golang ServicePlanFields.Name怎麽用?Golang ServicePlanFields.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cf/models.ServicePlanFields的用法示例。


在下文中一共展示了ServicePlanFields.Name方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
}
開發者ID:juggernaut,項目名稱:cli,代碼行數:26,代碼來源:service_summary.go

示例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
}
開發者ID:knolleary,項目名稱:cli,代碼行數:10,代碼來源:service_response_types.go

示例3:

	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,
		)
開發者ID:juggernaut,項目名稱:cli,代碼行數:30,代碼來源:create_service_test.go

示例4:

		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)

		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Service instance:", "service1"},
開發者ID:knolleary,項目名稱:cli,代碼行數:31,代碼來源:show_service_test.go


注:本文中的cf/models.ServicePlanFields.Name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。