예제 #1
0
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
0
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
0
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
0
	"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
0
			})
		})
	})

	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
0
	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
0
		})

		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"}
				})