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

ccv3.Client : replace usages of newHTTPRequet when possible #6

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: 7 additions & 8 deletions actor/v7action/application.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v7action

import (
"code.cloudfoundry.org/cli/resources"
"time"

"code.cloudfoundry.org/cli/actor/actionerror"
Expand Down Expand Up @@ -105,14 +106,12 @@ func (actor Actor) GetApplicationsBySpace(spaceGUID string) ([]Application, Warn
// name in the given space.
func (actor Actor) CreateApplicationInSpace(app Application, spaceGUID string) (Application, Warnings, error) {
createdApp, warnings, err := actor.CloudControllerClient.CreateApplication(
ccv3.Application{
resources.Application{
LifecycleType: app.LifecycleType,
LifecycleBuildpacks: app.LifecycleBuildpacks,
StackName: app.StackName,
Name: app.Name,
Relationships: ccv3.Relationships{
constant.RelationshipTypeSpace: ccv3.Relationship{GUID: spaceGUID},
},
SpaceGUID: spaceGUID,
})

if err != nil {
Expand Down Expand Up @@ -219,12 +218,12 @@ func (actor Actor) PollStart(appGUID string) (Warnings, error) {

// UpdateApplication updates the buildpacks on an application
func (actor Actor) UpdateApplication(app Application) (Application, Warnings, error) {
ccApp := ccv3.Application{
ccApp := resources.Application{
GUID: app.GUID,
StackName: app.StackName,
LifecycleType: app.LifecycleType,
LifecycleBuildpacks: app.LifecycleBuildpacks,
Metadata: (*ccv3.Metadata)(app.Metadata),
Metadata: (*resources.Metadata)(app.Metadata),
}

updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplication(ccApp)
Expand All @@ -235,7 +234,7 @@ func (actor Actor) UpdateApplication(app Application) (Application, Warnings, er
return actor.convertCCToActorApplication(updatedApp), Warnings(warnings), nil
}

func (Actor) convertCCToActorApplication(app ccv3.Application) Application {
func (Actor) convertCCToActorApplication(app resources.Application) Application {
return Application{
GUID: app.GUID,
StackName: app.StackName,
Expand All @@ -247,7 +246,7 @@ func (Actor) convertCCToActorApplication(app ccv3.Application) Application {
}
}

func (actor Actor) shouldContinuePollingProcessStatus(process ccv3.Process) (bool, Warnings, error) {
func (actor Actor) shouldContinuePollingProcessStatus(process resources.Process) (bool, Warnings, error) {
ccInstances, ccWarnings, err := actor.CloudControllerClient.GetProcessInstances(process.GUID)
instances := ProcessInstances(ccInstances)
warnings := Warnings(ccWarnings)
Expand Down
5 changes: 3 additions & 2 deletions actor/v7action/application_manifest_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v7action_test

import (
"code.cloudfoundry.org/cli/resources"
"errors"

"code.cloudfoundry.org/cli/actor/actionerror"
Expand Down Expand Up @@ -58,7 +59,7 @@ var _ = Describe("Application Manifest Actions", func() {
When("the app exists", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetApplicationsReturns(
[]ccv3.Application{{GUID: "app-1-guid"}},
[]resources.Application{{GUID: "app-1-guid"}},
ccv3.Warnings{"app-1-warning"},
nil,
)
Expand Down Expand Up @@ -224,7 +225,7 @@ var _ = Describe("Application Manifest Actions", func() {
When("getting the application is successful", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetApplicationsReturns(
[]ccv3.Application{
[]resources.Application{
{Name: appName, GUID: "some-app-guid"},
},
ccv3.Warnings{"get-application-warning"},
Expand Down
23 changes: 12 additions & 11 deletions actor/v7action/application_summary_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v7action_test

import (
"code.cloudfoundry.org/cli/resources"
"errors"

"code.cloudfoundry.org/cli/actor/v2action"
Expand Down Expand Up @@ -91,7 +92,7 @@ var _ = Describe("Application Summary Actions", func() {
When("retrieving the application is successful", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetApplicationsReturns(
[]ccv3.Application{
[]resources.Application{
{
Name: "some-app-name",
GUID: "some-app-guid",
Expand All @@ -105,7 +106,7 @@ var _ = Describe("Application Summary Actions", func() {

When("retrieving the process information is successful", func() {
BeforeEach(func() {
listedProcesses := []ccv3.Process{
listedProcesses := []resources.Process{
{
GUID: "some-process-guid",
Type: "some-type",
Expand Down Expand Up @@ -161,9 +162,9 @@ var _ = Describe("Application Summary Actions", func() {
When("app has droplet", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetApplicationDropletCurrentReturns(
ccv3.Droplet{
resources.Droplet{
Stack: "some-stack",
Buildpacks: []ccv3.DropletBuildpack{
Buildpacks: []resources.DropletBuildpack{
{
Name: "some-buildpack",
},
Expand Down Expand Up @@ -262,7 +263,7 @@ var _ = Describe("Application Summary Actions", func() {
BeforeEach(func() {
expectedErr = errors.New("some error")
fakeCloudControllerClient.GetApplicationDropletCurrentReturns(
ccv3.Droplet{},
resources.Droplet{},
ccv3.Warnings{"some-droplet-warning"},
expectedErr,
)
Expand All @@ -278,7 +279,7 @@ var _ = Describe("Application Summary Actions", func() {
When("app does not have current droplet", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetApplicationDropletCurrentReturns(
ccv3.Droplet{},
resources.Droplet{},
ccv3.Warnings{"some-droplet-warning"},
ccerror.DropletNotFoundError{},
)
Expand Down Expand Up @@ -344,7 +345,7 @@ var _ = Describe("Application Summary Actions", func() {

BeforeEach(func() {
fakeCloudControllerClient.GetApplicationProcessesReturns(
[]ccv3.Process{
[]resources.Process{
{
GUID: "some-process-guid",
Type: "some-type",
Expand All @@ -355,7 +356,7 @@ var _ = Describe("Application Summary Actions", func() {
)

fakeCloudControllerClient.GetApplicationProcessByTypeReturns(
ccv3.Process{},
resources.Process{},
ccv3.Warnings{"get-process-by-type-warning"},
nil,
)
Expand All @@ -380,7 +381,7 @@ var _ = Describe("Application Summary Actions", func() {

BeforeEach(func() {
fakeCloudControllerClient.GetApplicationsReturns(
[]ccv3.Application{
[]resources.Application{
{
Name: "some-app-name",
GUID: "some-app-guid",
Expand All @@ -393,7 +394,7 @@ var _ = Describe("Application Summary Actions", func() {

expectedErr = errors.New("some error")
fakeCloudControllerClient.GetApplicationProcessesReturns(
[]ccv3.Process{{Type: constant.ProcessTypeWeb}},
[]resources.Process{{Type: constant.ProcessTypeWeb}},
ccv3.Warnings{"some-process-warning"},
expectedErr,
)
Expand All @@ -409,7 +410,7 @@ var _ = Describe("Application Summary Actions", func() {
When("passed with a routeActor", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetApplicationsReturns(
[]ccv3.Application{
[]resources.Application{
{
Name: "some-app-name",
GUID: "some-app-guid",
Expand Down
Loading