本文整理匯總了Golang中cf.ServiceInstance.ServiceOffering方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceInstance.ServiceOffering方法的具體用法?Golang ServiceInstance.ServiceOffering怎麽用?Golang ServiceInstance.ServiceOffering使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf.ServiceInstance
的用法示例。
在下文中一共展示了ServiceInstance.ServiceOffering方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestServices
func TestServices(t *testing.T) {
plan := cf.ServicePlanFields{}
plan.Guid = "spark-guid"
plan.Name = "spark"
offering := cf.ServiceOfferingFields{}
offering.Label = "cleardb"
serviceInstance := cf.ServiceInstance{}
serviceInstance.Name = "my-service-1"
serviceInstance.ServicePlan = plan
serviceInstance.ApplicationNames = []string{"cli1", "cli2"}
serviceInstance.ServiceOffering = offering
plan2 := cf.ServicePlanFields{}
plan2.Guid = "spark-guid-2"
plan2.Name = "spark-2"
serviceInstance2 := cf.ServiceInstance{}
serviceInstance2.Name = "my-service-2"
serviceInstance2.ServicePlan = plan2
serviceInstance2.ApplicationNames = []string{"cli1"}
serviceInstance2.ServiceOffering = offering
serviceInstance3 := cf.ServiceInstance{}
serviceInstance3.Name = "my-service-provided-by-user"
serviceInstances := []cf.ServiceInstance{serviceInstance, serviceInstance2, serviceInstance3}
serviceSummaryRepo := &testapi.FakeServiceSummaryRepo{
GetSummariesInCurrentSpaceInstances: serviceInstances,
}
ui := &testterm.FakeUI{}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
org := cf.OrganizationFields{}
org.Name = "my-org"
space := cf.SpaceFields{}
space.Name = "my-space"
config := &configuration.Configuration{
SpaceFields: space,
OrganizationFields: org,
AccessToken: token,
}
cmd := NewListServices(ui, config, serviceSummaryRepo)
cmd.Run(testcmd.NewContext("services", []string{}))
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Getting services in org", "my-org", "my-space", "my-user"},
{"OK"},
{"my-service-1", "cleardb", "spark", "cli1, cli2"},
{"my-service-2", "cleardb", "spark-2", "cli1"},
{"my-service-provided-by-user", "user-provided"},
})
}
示例2: ToModels
func (resource ServiceInstancesSummaries) ToModels() (instances []cf.ServiceInstance) {
for _, instanceSummary := range resource.ServiceInstances {
applicationNames := resource.findApplicationNamesForInstance(instanceSummary.Name)
planSummary := instanceSummary.ServicePlan
servicePlan := cf.ServicePlanFields{}
servicePlan.Name = planSummary.Name
servicePlan.Guid = planSummary.Guid
offeringSummary := planSummary.ServiceOffering
serviceOffering := cf.ServiceOfferingFields{}
serviceOffering.Label = offeringSummary.Label
serviceOffering.Provider = offeringSummary.Provider
serviceOffering.Version = offeringSummary.Version
instance := cf.ServiceInstance{}
instance.Name = instanceSummary.Name
instance.ApplicationNames = applicationNames
instance.ServicePlan = servicePlan
instance.ServiceOffering = serviceOffering
instances = append(instances, instance)
}
return
}
示例3: TestShowServiceOutput
func TestShowServiceOutput(t *testing.T) {
offering := cf.ServiceOfferingFields{}
offering.Label = "mysql"
offering.DocumentationUrl = "http://documentation.url"
offering.Description = "the-description"
plan := cf.ServicePlanFields{}
plan.Guid = "plan-guid"
plan.Name = "plan-name"
serviceInstance := cf.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(t, ui.Outputs, testassert.Lines{
{"Service instance:", "service1"},
{"Service: ", "mysql"},
{"Plan: ", "plan-name"},
{"Description: ", "the-description"},
{"Documentation url: ", "http://documentation.url"},
})
}