Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v8(services): remove detection of UPSI for keys #2140

Merged
merged 1 commit into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions actor/v7action/service_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,6 @@ func (actor Actor) getServiceInstanceByNameAndSpace(serviceInstanceName string,
}
}

func (actor Actor) getManagedServiceInstanceByNameAndSpace(serviceInstanceName string, spaceGUID string, query ...ccv3.Query) (serviceInstance resources.ServiceInstance, included ccv3.IncludedResources, warnings ccv3.Warnings, err error) {
warnings, err = railway.Sequentially(
func() (warnings ccv3.Warnings, err error) {
serviceInstance, included, warnings, err = actor.getServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID, query...)
return
},
func() (warnings ccv3.Warnings, err error) {
err = assertServiceInstanceType(resources.ManagedServiceInstance, serviceInstance)
return
},
)

return serviceInstance, included, warnings, err
}

func (actor Actor) getServiceInstanceForUpdate(serviceInstanceName string, spaceGUID string, includePlan bool) (resources.ServiceInstance, resources.ServiceOffering, resources.ServiceBroker, ccv3.Warnings, error) {
var query []ccv3.Query
if includePlan {
Expand Down
4 changes: 2 additions & 2 deletions actor/v7action/service_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (actor Actor) GetServiceKeysByServiceInstance(serviceInstanceName, spaceGUI

warnings, err := railway.Sequentially(
func() (warnings ccv3.Warnings, err error) {
serviceInstance, _, warnings, err = actor.getManagedServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID)
serviceInstance, _, warnings, err = actor.getServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID)
return
},
func() (warnings ccv3.Warnings, err error) {
Expand Down Expand Up @@ -147,7 +147,7 @@ func (actor Actor) getServiceKeyByServiceInstanceAndName(serviceInstanceName, se

warnings, err := railway.Sequentially(
func() (warnings ccv3.Warnings, err error) {
serviceInstance, _, warnings, err = actor.getManagedServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID)
serviceInstance, _, warnings, err = actor.getServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID)
return
},
func() (warnings ccv3.Warnings, err error) {
Expand Down
69 changes: 0 additions & 69 deletions actor/v7action/service_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,29 +262,6 @@ var _ = Describe("Service Key Action", func() {
}))
})

When("service instance is user-provided", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetServiceInstanceByNameAndSpaceReturns(
resources.ServiceInstance{
Name: serviceInstanceName,
GUID: serviceInstanceGUID,
Type: resources.UserProvidedServiceInstance,
},
ccv3.IncludedResources{},
ccv3.Warnings{"get instance warning"},
nil,
)
})

It("returns an error and warning", func() {
Expect(warnings).To(ContainElement("get instance warning"))
Expect(executionError).To(MatchError(actionerror.ServiceInstanceTypeError{
Name: serviceInstanceName,
RequiredType: resources.ManagedServiceInstance,
}))
})
})

When("service instance not found", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetServiceInstanceByNameAndSpaceReturns(
Expand Down Expand Up @@ -400,29 +377,6 @@ var _ = Describe("Service Key Action", func() {
Expect(key.GUID).To(Equal(serviceKeyGUID))
})

When("service instance is user-provided", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetServiceInstanceByNameAndSpaceReturns(
resources.ServiceInstance{
Name: serviceInstanceName,
GUID: serviceInstanceGUID,
Type: resources.UserProvidedServiceInstance,
},
ccv3.IncludedResources{},
ccv3.Warnings{"get instance warning"},
nil,
)
})

It("returns an error and warning", func() {
Expect(warnings).To(ContainElement("get instance warning"))
Expect(executionError).To(MatchError(actionerror.ServiceInstanceTypeError{
Name: serviceInstanceName,
RequiredType: resources.ManagedServiceInstance,
}))
})
})

When("service instance not found", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetServiceInstanceByNameAndSpaceReturns(
Expand Down Expand Up @@ -568,29 +522,6 @@ var _ = Describe("Service Key Action", func() {
Expect(details.Credentials).To(Equal(types.JSONObject{"foo": "bar"}))
})

When("service instance is user-provided", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetServiceInstanceByNameAndSpaceReturns(
resources.ServiceInstance{
Name: serviceInstanceName,
GUID: serviceInstanceGUID,
Type: resources.UserProvidedServiceInstance,
},
ccv3.IncludedResources{},
ccv3.Warnings{"get instance warning"},
nil,
)
})

It("returns an error and warning", func() {
Expect(warnings).To(ContainElement("get instance warning"))
Expect(executionError).To(MatchError(actionerror.ServiceInstanceTypeError{
Name: serviceInstanceName,
RequiredType: resources.ManagedServiceInstance,
}))
})
})

When("service instance not found", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetServiceInstanceByNameAndSpaceReturns(
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions command/v7/delete_service_key_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ func (cmd DeleteServiceKeyCommand) Execute(args []string) error {
cmd.displayNotFound()
case actionerror.ServiceInstanceNotFoundError:
return translatableerror.ServiceInstanceNotFoundError{Name: cmd.RequiredArgs.ServiceInstance}
case actionerror.ServiceInstanceTypeError:
return translatableerror.ServiceKeysNotSupportedWithUserProvidedServiceInstances{}
default:
return err
}
Expand Down
21 changes: 1 addition & 20 deletions command/v7/delete_service_key_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"code.cloudfoundry.org/cli/command/translatableerror"
v7 "code.cloudfoundry.org/cli/command/v7"
"code.cloudfoundry.org/cli/command/v7/v7fakes"
"code.cloudfoundry.org/cli/resources"
"code.cloudfoundry.org/cli/util/configv3"
"code.cloudfoundry.org/cli/util/ui"
. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -175,25 +174,7 @@ var _ = Describe("delete-service-key Command", func() {
})
})

When("service instance is user-provided", func() {
BeforeEach(func() {
fakeActor.DeleteServiceKeyByServiceInstanceAndNameReturns(
nil,
v7action.Warnings{"upsi warning"},
actionerror.ServiceInstanceTypeError{
Name: fakeServiceInstanceName,
RequiredType: resources.ManagedServiceInstance,
},
)
})

It("returns an appropriate error", func() {
Expect(testUI.Err).To(Say("upsi warning"))
Expect(executeErr).To(MatchError(translatableerror.ServiceKeysNotSupportedWithUserProvidedServiceInstances{}))
})
})

When("there is another error", func() {
When("there is an error", func() {
BeforeEach(func() {
fakeActor.DeleteServiceKeyByServiceInstanceAndNameReturns(
nil,
Expand Down
11 changes: 1 addition & 10 deletions command/v7/service_key_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package v7
import (
"encoding/json"

"code.cloudfoundry.org/cli/actor/actionerror"
"code.cloudfoundry.org/cli/command/flag"
"code.cloudfoundry.org/cli/command/translatableerror"
)

type ServiceKeyCommand struct {
Expand Down Expand Up @@ -46,9 +44,6 @@ func (cmd ServiceKeyCommand) guid() error {
case nil:
cmd.UI.DisplayText(key.GUID)
return nil
case actionerror.ServiceInstanceTypeError:
cmd.UI.DisplayWarnings(warnings)
return translatableerror.ServiceKeysNotSupportedWithUserProvidedServiceInstances{}
default:
cmd.UI.DisplayWarnings(warnings)
return err
Expand All @@ -73,11 +68,7 @@ func (cmd ServiceKeyCommand) details() error {
cmd.Config.TargetedSpace().GUID,
)
cmd.UI.DisplayWarnings(warnings)
switch err.(type) {
case nil:
case actionerror.ServiceInstanceTypeError:
return translatableerror.ServiceKeysNotSupportedWithUserProvidedServiceInstances{}
default:
if err != nil {
return err
}

Expand Down
40 changes: 1 addition & 39 deletions command/v7/service_key_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import (

"code.cloudfoundry.org/cli/types"

"code.cloudfoundry.org/cli/actor/actionerror"
"code.cloudfoundry.org/cli/actor/v7action"
"code.cloudfoundry.org/cli/command/commandfakes"
"code.cloudfoundry.org/cli/command/translatableerror"
v7 "code.cloudfoundry.org/cli/command/v7"
"code.cloudfoundry.org/cli/command/v7/v7fakes"
"code.cloudfoundry.org/cli/resources"
Expand Down Expand Up @@ -113,24 +111,6 @@ var _ = Describe("service-key Command", func() {
})
})

When("not a managed service instance", func() {
BeforeEach(func() {
fakeActor.GetServiceKeyDetailsByServiceInstanceAndNameReturns(
resources.ServiceCredentialBindingDetails{},
v7action.Warnings{"a warning"},
actionerror.ServiceInstanceTypeError{
Name: fakeServiceInstanceName,
RequiredType: resources.ManagedServiceInstance,
},
)
})

It("prints warnings and returns an error", func() {
Expect(testUI.Err).To(Say("a warning"))
Expect(executeErr).To(MatchError(translatableerror.ServiceKeysNotSupportedWithUserProvidedServiceInstances{}))
})
})

When("actor returns another error", func() {
BeforeEach(func() {
fakeActor.GetServiceKeyDetailsByServiceInstanceAndNameReturns(
Expand Down Expand Up @@ -173,25 +153,7 @@ var _ = Describe("service-key Command", func() {
Expect(testUI.Err).NotTo(Say("a warning"))
})

When("not a managed service instance", func() {
BeforeEach(func() {
fakeActor.GetServiceKeyByServiceInstanceAndNameReturns(
resources.ServiceCredentialBinding{},
v7action.Warnings{"a warning"},
actionerror.ServiceInstanceTypeError{
Name: fakeServiceInstanceName,
RequiredType: resources.ManagedServiceInstance,
},
)
})

It("prints warnings and returns an error", func() {
Expect(testUI.Err).To(Say("a warning"))
Expect(executeErr).To(MatchError(translatableerror.ServiceKeysNotSupportedWithUserProvidedServiceInstances{}))
})
})

When("actor returns another error", func() {
When("actor returns an error", func() {
BeforeEach(func() {
fakeActor.GetServiceKeyByServiceInstanceAndNameReturns(
resources.ServiceCredentialBinding{},
Expand Down
8 changes: 1 addition & 7 deletions command/v7/service_keys_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package v7
import (
"fmt"

"code.cloudfoundry.org/cli/actor/actionerror"
"code.cloudfoundry.org/cli/command/flag"
"code.cloudfoundry.org/cli/command/translatableerror"
"code.cloudfoundry.org/cli/resources"
"code.cloudfoundry.org/cli/util/ui"
)
Expand All @@ -31,11 +29,7 @@ func (cmd ServiceKeysCommand) Execute(args []string) error {
cmd.Config.TargetedSpace().GUID,
)
cmd.UI.DisplayWarnings(warnings)
switch err.(type) {
case nil:
case actionerror.ServiceInstanceTypeError:
return translatableerror.ServiceKeysNotSupportedWithUserProvidedServiceInstances{}
default:
if err != nil {
return err
}

Expand Down
17 changes: 0 additions & 17 deletions command/v7/service_keys_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package v7_test
import (
"errors"

"code.cloudfoundry.org/cli/actor/actionerror"
"code.cloudfoundry.org/cli/actor/v7action"
"code.cloudfoundry.org/cli/command/commandfakes"
"code.cloudfoundry.org/cli/command/translatableerror"
v7 "code.cloudfoundry.org/cli/command/v7"
"code.cloudfoundry.org/cli/command/v7/v7fakes"
"code.cloudfoundry.org/cli/resources"
Expand Down Expand Up @@ -120,21 +118,6 @@ var _ = Describe("service-keys Command", func() {
})
})

When("the service instance is user-provided", func() {
BeforeEach(func() {
fakeActor.GetServiceKeysByServiceInstanceReturns(
nil,
v7action.Warnings{"fake warning"},
actionerror.ServiceInstanceTypeError{},
)
})

It("returns a helpful error and prints warnings", func() {
Expect(testUI.Err).To(Say("fake warning"))
Expect(executeErr).To(MatchError(translatableerror.ServiceKeysNotSupportedWithUserProvidedServiceInstances{}))
})
})

When("checking the target returns an error", func() {
BeforeEach(func() {
fakeSharedActor.CheckTargetReturns(errors.New("explode"))
Expand Down
23 changes: 1 addition & 22 deletions integration/v7/isolated/service_key_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,7 @@ var _ = Describe("service-key command", func() {
})
})

When("service instance is user-provided", func() {
var serviceInstance string

BeforeEach(func() {
serviceInstance = helpers.NewServiceInstanceName()
Eventually(helpers.CF("cups", serviceInstance)).Should(Exit(0))
})

It("reports a helpful error", func() {
session := helpers.CF(command, serviceInstance, "no-such-key")
Eventually(session).Should(Exit(1))

Expect(session.Out).To(SatisfyAll(
Say(`Getting key no-such-key for service instance %s as %s\.\.\.\n`, serviceInstance, username),
Say(`FAILED\n`),
))

Expect(session.Err).To(Say(`Service keys are not supported for user-provided service instances`))
})
})

When("service instance is managed", func() {
When("service instance exists", func() {
var (
broker *servicebrokerstub.ServiceBrokerStub
serviceInstance string
Expand Down
Loading