Skip to content
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
3 changes: 2 additions & 1 deletion actor/v7action/cloud_controller_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type CloudControllerClient interface {
GetEvents(query ...ccv3.Query) ([]ccv3.Event, ccv3.Warnings, error)
GetFeatureFlag(featureFlagName string) (resources.FeatureFlag, ccv3.Warnings, error)
GetFeatureFlags() ([]resources.FeatureFlag, ccv3.Warnings, error)
GetRoot() (ccv3.Root, ccv3.Warnings, error)
GetInfo() (ccv3.Info, ccv3.Warnings, error)
GetIsolationSegment(guid string) (resources.IsolationSegment, ccv3.Warnings, error)
GetIsolationSegmentOrganizations(isolationSegmentGUID string) ([]resources.Organization, ccv3.Warnings, error)
Expand Down Expand Up @@ -148,7 +149,7 @@ type CloudControllerClient interface {
PollJobToEventStream(jobURL ccv3.JobURL) chan ccv3.PollJobEvent
PurgeServiceOffering(serviceOfferingGUID string) (ccv3.Warnings, error)
ResourceMatch(resources []ccv3.Resource) ([]ccv3.Resource, ccv3.Warnings, error)
RootResponse() (ccv3.Info, ccv3.Warnings, error)
RootResponse() (ccv3.Root, ccv3.Warnings, error)
SetApplicationDroplet(appGUID string, dropletGUID string) (resources.Relationship, ccv3.Warnings, error)
SharePrivateDomainToOrgs(domainGuid string, sharedOrgs ccv3.SharedOrgs) (ccv3.Warnings, error)
ShareServiceInstanceToSpaces(serviceInstanceGUID string, spaceGUIDs []string) (resources.RelationshipList, ccv3.Warnings, error)
Expand Down
11 changes: 10 additions & 1 deletion actor/v7action/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@ package v7action

import "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"

type Root ccv3.Root
type Info ccv3.Info

func (actor Actor) GetRootResponse() (Info, Warnings, error) {
func (actor Actor) GetRootResponse() (Root, Warnings, error) {
root, warnings, err := actor.CloudControllerClient.GetRoot()
if err != nil {
return Root{}, Warnings(warnings), err
}
return Root(root), Warnings(warnings), nil
}

func (actor Actor) GetInfoResponse() (Info, Warnings, error) {
info, warnings, err := actor.CloudControllerClient.GetInfo()
if err != nil {
return Info{}, Warnings(warnings), err
Expand Down
59 changes: 53 additions & 6 deletions actor/v7action/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ var _ = Describe("Info Actions", func() {
})

Describe("GetRootResponse", func() {
When("getting info is successful", func() {
When("getting root is successful", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetInfoReturns(
ccv3.Info{
Links: ccv3.InfoLinks{
fakeCloudControllerClient.GetRootReturns(
ccv3.Root{
Links: ccv3.RootLinks{
LogCache: resources.APILink{HREF: "some-log-cache-url"},
},
},
Expand All @@ -42,11 +42,58 @@ var _ = Describe("Info Actions", func() {

Expect(warnings).To(ConsistOf("warning-1", "warning-2"))

Expect(fakeCloudControllerClient.GetInfoCallCount()).To(Equal(1))
Expect(fakeCloudControllerClient.GetRootCallCount()).To(Equal(1))
Expect(rootInfo.Links.LogCache.HREF).To(Equal("some-log-cache-url"))
})
})

When("the cloud controller client returns an error", func() {
var expectedErr error

BeforeEach(func() {
expectedErr = errors.New("I am a CloudControllerClient Error")
fakeCloudControllerClient.GetRootReturns(
ccv3.Root{},
ccv3.Warnings{"warning-1", "warning-2"},
expectedErr,
)
})

It("returns the same error and all warnings", func() {
_, warnings, err := actor.GetRootResponse()
Expect(err).To(MatchError(expectedErr))
Expect(warnings).To(ConsistOf("warning-1", "warning-2"))
})
})
})

Describe("GetInfoResponse", func() {
When("getting info is successful", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetInfoReturns(
ccv3.Info{
Name: "test-name",
Build: "test-build",
OSBAPIVersion: "1.0",
},
ccv3.Warnings{"warning-1", "warning-2"},
nil,
)
})

It("returns all warnings and info", func() {
info, warnings, err := actor.GetInfoResponse()
Expect(err).ToNot(HaveOccurred())

Expect(warnings).To(ConsistOf("warning-1", "warning-2"))

Expect(fakeCloudControllerClient.GetInfoCallCount()).To(Equal(1))
Expect(info.Name).To(Equal("test-name"))
Expect(info.Build).To(Equal("test-build"))
Expect(info.OSBAPIVersion).To(Equal("1.0"))
})
})

When("the cloud controller client returns an error", func() {
var expectedErr error

Expand All @@ -60,7 +107,7 @@ var _ = Describe("Info Actions", func() {
})

It("returns the same error and all warnings", func() {
_, warnings, err := actor.GetRootResponse()
_, warnings, err := actor.GetInfoResponse()
Expect(err).To(MatchError(expectedErr))
Expect(warnings).To(ConsistOf("warning-1", "warning-2"))
})
Expand Down
2 changes: 1 addition & 1 deletion actor/v7action/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (actor Actor) GetSecureShellConfigurationByApplicationNameSpaceProcessTypeA
) (SSHAuthentication, Warnings, error) {
var allWarnings Warnings

rootInfo, warnings, err := actor.CloudControllerClient.GetInfo()
rootInfo, warnings, err := actor.CloudControllerClient.GetRoot()
allWarnings = append(allWarnings, warnings...)
if err != nil {
return SSHAuthentication{}, allWarnings, err
Expand Down
12 changes: 6 additions & 6 deletions actor/v7action/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ var _ = Describe("SSH Actions", func() {

When("the app ssh endpoint is empty", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetInfoReturns(ccv3.Info{
Links: ccv3.InfoLinks{
fakeCloudControllerClient.GetRootReturns(ccv3.Root{
Links: ccv3.RootLinks{
AppSSH: resources.APILink{HREF: ""},
},
}, nil, nil)
Expand All @@ -106,8 +106,8 @@ var _ = Describe("SSH Actions", func() {

When("the app ssh hostkey fingerprint is empty", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetInfoReturns(ccv3.Info{
Links: ccv3.InfoLinks{
fakeCloudControllerClient.GetRootReturns(ccv3.Root{
Links: ccv3.RootLinks{
AppSSH: resources.APILink{HREF: "some-app-ssh-endpoint"},
},
}, nil, nil)
Expand All @@ -120,8 +120,8 @@ var _ = Describe("SSH Actions", func() {

When("ssh endpoint and fingerprint are set", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetInfoReturns(ccv3.Info{
Links: ccv3.InfoLinks{
fakeCloudControllerClient.GetRootReturns(ccv3.Root{
Links: ccv3.RootLinks{
AppSSH: resources.APILink{
HREF: "some-app-ssh-endpoint",
Meta: resources.APILinkMeta{HostKeyFingerprint: "some-app-ssh-fingerprint"},
Expand Down
2 changes: 1 addition & 1 deletion actor/v7action/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (actor Actor) SetTarget(settings TargetSettings) (Warnings, error) {

actor.CloudControllerClient.TargetCF(ccv3.TargetSettings(settings))

rootInfo, warnings, err := actor.CloudControllerClient.GetInfo()
rootInfo, warnings, err := actor.CloudControllerClient.GetRoot()
allWarnings = append(allWarnings, warnings...)
if err != nil {
return allWarnings, err
Expand Down
10 changes: 5 additions & 5 deletions actor/v7action/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ var _ = Describe("Targeting", func() {
}
meta.Version = expectedAPIVersion

rootResponse := ccv3.Info{
Links: ccv3.InfoLinks{
rootResponse := ccv3.Root{
Links: ccv3.RootLinks{
CCV3: resources.APILink{
Meta: meta,
},
Expand All @@ -76,7 +76,7 @@ var _ = Describe("Targeting", func() {
},
},
}
fakeCloudControllerClient.GetInfoReturns(rootResponse, ccv3.Warnings{"info-warning"}, nil)
fakeCloudControllerClient.GetRootReturns(rootResponse, ccv3.Warnings{"info-warning"}, nil)
})

JustBeforeEach(func() {
Expand All @@ -96,7 +96,7 @@ var _ = Describe("Targeting", func() {

When("getting root info fails", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetInfoReturns(ccv3.Info{}, ccv3.Warnings{"info-warning"}, errors.New("info-error"))
fakeCloudControllerClient.GetRootReturns(ccv3.Root{}, ccv3.Warnings{"info-warning"}, errors.New("info-error"))
})

It("returns an error and all warnings", func() {
Expand Down Expand Up @@ -145,7 +145,7 @@ var _ = Describe("Targeting", func() {

When("deployed on Kubernetes", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetInfoReturns(ccv3.Info{CFOnK8s: true}, nil, nil)
fakeCloudControllerClient.GetRootReturns(ccv3.Root{CFOnK8s: true}, nil, nil)
})

It("sets the CFOnK8s target information", func() {
Expand Down
95 changes: 85 additions & 10 deletions actor/v7action/v7actionfakes/fake_cloud_controller_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/cloudcontroller/ccv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type Warnings []string

// Client can be used to talk to a Cloud Controller's V3 Endpoints.
type Client struct {
Info
Root
CloudControllerURL string

Requester
Expand Down
2 changes: 1 addition & 1 deletion api/cloudcontroller/ccv3/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var _ = Describe("Cloud Controller Client", func() {
})

It("adds a user agent header", func() {
_, _, err := client.GetInfo()
_, _, err := client.GetRoot()
Expect(err).ToNot(HaveOccurred())
Expect(server.ReceivedRequests()).To(HaveLen(1))
})
Expand Down
Loading
Loading