本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/models.ServiceOffering類的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceOffering類的具體用法?Golang ServiceOffering怎麽用?Golang ServiceOffering使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ServiceOffering類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ToModel
func (resource ServiceOfferingResource) ToModel() models.ServiceOffering {
offering := models.ServiceOffering{
ServiceOfferingFields: resource.ToFields(),
}
for _, p := range resource.Entity.ServicePlans {
offering.Plans = append(offering.Plans,
models.ServicePlanFields{
Name: p.Entity.Name,
GUID: p.Metadata.GUID,
},
)
}
return offering
}
示例2: attachPlansToService
func (builder Builder) attachPlansToService(service models.ServiceOffering) (models.ServiceOffering, error) {
plans, err := builder.planBuilder.GetPlansForServiceWithOrgs(service.GUID)
if err != nil {
return models.ServiceOffering{}, err
}
service.Plans = plans
return service, nil
}
示例3: attachPlansToServiceForOrg
func (builder Builder) attachPlansToServiceForOrg(service models.ServiceOffering, orgName string) (models.ServiceOffering, error) {
plans, err := builder.planBuilder.GetPlansForServiceForOrg(service.GUID, orgName)
if err != nil {
return models.ServiceOffering{}, err
}
service.Plans = plans
return service, nil
}
示例4:
"code.cloudfoundry.org/cli/cf/commandregistry"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "code.cloudfoundry.org/cli/testhelpers/matchers"
)
var _ = Describe("create-service command", func() {
var (
ui *testterm.FakeUI
config coreconfig.Repository
requirementsFactory *requirementsfakes.FakeFactory
serviceRepo *apifakes.FakeServiceRepository
serviceBuilder *servicebuilderfakes.FakeServiceBuilder
offering1 models.ServiceOffering
offering2 models.ServiceOffering
deps commandregistry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.Config = config
deps.RepoLocator = deps.RepoLocator.SetServiceRepository(serviceRepo)
deps.ServiceBuilder = serviceBuilder
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("create-service").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
示例5:
})
})
})
Describe("PurgeServiceOffering", func() {
It("purges service offerings", func() {
setupTestServer(testnet.TestRequest{
Method: "DELETE",
Path: "/v2/services/the-service-guid?purge=true",
Response: testnet.TestResponse{
Status: 204,
}})
offering := models.ServiceOffering{ServiceOfferingFields: models.ServiceOfferingFields{
Label: "the-offering",
GUID: "the-service-guid",
Description: "some service description",
}}
offering.GUID = "the-service-guid"
err := repo.PurgeServiceOffering(offering)
Expect(err).NotTo(HaveOccurred())
Expect(testHandler).To(HaveAllRequestsCalled())
})
})
Describe("PurgeServiceInstance", func() {
It("purges service instances", func() {
setupTestServer(testnet.TestRequest{
Method: "DELETE",
Path: "/v2/service_instances/instance-guid?purge=true",
示例6:
testconfig "code.cloudfoundry.org/cli/testhelpers/configuration"
testterm "code.cloudfoundry.org/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"code.cloudfoundry.org/cli/cf/commands/service"
"code.cloudfoundry.org/cli/cf/flags"
. "code.cloudfoundry.org/cli/testhelpers/matchers"
)
var _ = Describe("update-service command", func() {
var (
ui *testterm.FakeUI
config coreconfig.Repository
requirementsFactory *requirementsfakes.FakeFactory
serviceRepo *apifakes.FakeServiceRepository
planBuilder *planbuilderfakes.FakePlanBuilder
offering1 models.ServiceOffering
deps commandregistry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.RepoLocator = deps.RepoLocator.SetServiceRepository(serviceRepo)
deps.Config = config
deps.PlanBuilder = planBuilder
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("update-service").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
示例7:
})
JustBeforeEach(func() {
runCLIErr = cmd.Execute(flagContext)
})
It("tries to find the service offering by label", func() {
Expect(runCLIErr).NotTo(HaveOccurred())
Expect(serviceRepo.FindServiceOfferingsByLabelCallCount()).To(Equal(1))
name := serviceRepo.FindServiceOfferingsByLabelArgsForCall(0)
Expect(name).To(Equal("service-name"))
})
Context("when finding the service offering succeeds", func() {
BeforeEach(func() {
serviceOffering := models.ServiceOffering{}
serviceOffering.GUID = "service-offering-guid"
serviceRepo.FindServiceOfferingsByLabelReturns([]models.ServiceOffering{serviceOffering}, nil)
ui.Inputs = []string{"n"}
})
It("asks the user to confirm", func() {
Expect(runCLIErr).NotTo(HaveOccurred())
Expect(ui.Outputs()).To(ContainSubstrings([]string{"WARNING"}))
Expect(ui.Prompts).To(ContainSubstrings([]string{"Really purge service offering service-name from Cloud Foundry?"}))
})
Context("when the user confirms", func() {
BeforeEach(func() {
ui.Inputs = []string{"y"}
})