本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/models.ServiceOffering類的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceOffering類的具體用法?Golang ServiceOffering怎麽用?Golang ServiceOffering使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ServiceOffering類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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.GetPlansForService(service.Guid)
if err != nil {
return models.ServiceOffering{}, err
}
service.Plans = plans
return service, nil
}
示例3:
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/cloudfoundry/cli/cf/commands/service"
"github.com/cloudfoundry/cli/cf/flags"
. "github.com/cloudfoundry/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{}
示例4:
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("create-service command", func() {
var (
ui *testterm.FakeUI
config configuration.Repository
requirementsFactory *testreq.FakeReqFactory
cmd CreateService
serviceRepo *testapi.FakeServiceRepo
offering1 models.ServiceOffering
offering2 models.ServiceOffering
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
config = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
serviceRepo = &testapi.FakeServiceRepo{}
cmd = NewCreateService(ui, config, serviceRepo)
offering1 = models.ServiceOffering{}
offering1.Label = "cleardb"
offering1.Plans = []models.ServicePlanFields{{
示例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:
"github.com/cloudfoundry/cli/cf/commandregistry"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/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() {
示例7:
Expect(err).NotTo(HaveOccurred())
cmd.Requirements(factory, flagContext)
})
It("tries to find the service offering by label", func() {
ui.Inputs = []string{"n"}
serviceRepo.FindServiceOfferingsByLabelReturns([]models.ServiceOffering{{}}, nil)
cmd.Execute(flagContext)
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)
})
It("asks the user to confirm", func() {
ui.Inputs = []string{"n"}
cmd.Execute(flagContext)
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"}
})
示例8:
_, err = cmd.Requirements(factory, flagContext)
Expect(err).NotTo(HaveOccurred())
})
It("tries to find the service offering by label", func() {
ui.Inputs = []string{"n"}
serviceRepo.FindServiceOfferingsByLabelReturns([]models.ServiceOffering{{}}, nil)
cmd.Execute(flagContext)
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)
})
It("asks the user to confirm", func() {
ui.Inputs = []string{"n"}
cmd.Execute(flagContext)
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"}
})