Skip to content

Commit

Permalink
Remove direct requirement of github.com/tedsuo/rata
Browse files Browse the repository at this point in the history
Signed-off-by: João Pereira <[email protected]>
  • Loading branch information
joaopapereira committed Nov 20, 2024
1 parent 6b87db8 commit aa1a29f
Show file tree
Hide file tree
Showing 63 changed files with 408 additions and 345 deletions.
17 changes: 9 additions & 8 deletions api/cloudcontroller/ccv3/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package ccv3

import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
ccv3internal "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
"code.cloudfoundry.org/cli/api/internal"
"code.cloudfoundry.org/cli/resources"
)

Expand All @@ -11,7 +12,7 @@ func (client *Client) CreateApplication(app resources.Application) (resources.Ap
var responseBody resources.Application

_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PostApplicationRequest,
RequestName: ccv3internal.PostApplicationRequest,
RequestBody: app,
ResponseBody: &responseBody,
})
Expand Down Expand Up @@ -42,7 +43,7 @@ func (client *Client) GetApplications(query ...Query) ([]resources.Application,
var apps []resources.Application

_, warnings, err := client.MakeListRequest(RequestParams{
RequestName: internal.GetApplicationsRequest,
RequestName: ccv3internal.GetApplicationsRequest,
Query: query,
ResponseBody: resources.Application{},
AppendToList: func(item interface{}) error {
Expand All @@ -59,7 +60,7 @@ func (client *Client) UpdateApplication(app resources.Application) (resources.Ap
var responseBody resources.Application

_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PatchApplicationRequest,
RequestName: ccv3internal.PatchApplicationRequest,
URIParams: internal.Params{"app_guid": app.GUID},
RequestBody: app,
ResponseBody: &responseBody,
Expand All @@ -72,7 +73,7 @@ func (client *Client) UpdateApplication(app resources.Application) (resources.Ap
func (client *Client) UpdateApplicationName(newAppName string, appGUID string) (resources.Application, Warnings, error) {
var responseBody resources.Application
_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PatchApplicationRequest,
RequestName: ccv3internal.PatchApplicationRequest,
URIParams: internal.Params{"app_guid": appGUID},
RequestBody: resources.ApplicationNameOnly{Name: newAppName},
ResponseBody: &responseBody,
Expand All @@ -86,7 +87,7 @@ func (client *Client) UpdateApplicationRestart(appGUID string) (resources.Applic
var responseBody resources.Application

_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PostApplicationActionRestartRequest,
RequestName: ccv3internal.PostApplicationActionRestartRequest,
URIParams: internal.Params{"app_guid": appGUID},
ResponseBody: &responseBody,
})
Expand All @@ -99,7 +100,7 @@ func (client *Client) UpdateApplicationStart(appGUID string) (resources.Applicat
var responseBody resources.Application

_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PostApplicationActionStartRequest,
RequestName: ccv3internal.PostApplicationActionStartRequest,
URIParams: internal.Params{"app_guid": appGUID},
ResponseBody: &responseBody,
})
Expand All @@ -112,7 +113,7 @@ func (client *Client) UpdateApplicationStop(appGUID string) (resources.Applicati
var responseBody resources.Application

_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PostApplicationActionStopRequest,
RequestName: ccv3internal.PostApplicationActionStopRequest,
URIParams: internal.Params{"app_guid": appGUID},
ResponseBody: &responseBody,
})
Expand Down
9 changes: 5 additions & 4 deletions api/cloudcontroller/ccv3/application_feature.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package ccv3

import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
ccv3internal "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
"code.cloudfoundry.org/cli/api/internal"
"code.cloudfoundry.org/cli/resources"
)

Expand All @@ -14,7 +15,7 @@ func (client *Client) GetAppFeature(appGUID string, featureName string) (resourc
var responseBody resources.ApplicationFeature

_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.GetApplicationFeaturesRequest,
RequestName: ccv3internal.GetApplicationFeaturesRequest,
URIParams: internal.Params{"app_guid": appGUID, "name": featureName},
ResponseBody: &responseBody,
})
Expand All @@ -26,7 +27,7 @@ func (client *Client) GetSSHEnabled(appGUID string) (SSHEnabled, Warnings, error
var responseBody SSHEnabled

_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.GetSSHEnabled,
RequestName: ccv3internal.GetSSHEnabled,
URIParams: internal.Params{"app_guid": appGUID},
ResponseBody: &responseBody,
})
Expand All @@ -37,7 +38,7 @@ func (client *Client) GetSSHEnabled(appGUID string) (SSHEnabled, Warnings, error
// UpdateAppFeature enables/disables the ability to ssh for a given application.
func (client *Client) UpdateAppFeature(appGUID string, enabled bool, featureName string) (Warnings, error) {
_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PatchApplicationFeaturesRequest,
RequestName: ccv3internal.PatchApplicationFeaturesRequest,
RequestBody: struct {
Enabled bool `json:"enabled"`
}{Enabled: enabled},
Expand Down
19 changes: 10 additions & 9 deletions api/cloudcontroller/ccv3/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
. "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
ccv3internal "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
"code.cloudfoundry.org/cli/api/internal"
"code.cloudfoundry.org/cli/resources"
"code.cloudfoundry.org/cli/types"
. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -279,7 +280,7 @@ var _ = Describe("Application", func() {
It("makes the correct request", func() {
Expect(requester.MakeRequestCallCount()).To(Equal(1))
actualParams := requester.MakeRequestArgsForCall(0)
Expect(actualParams.RequestName).To(Equal(internal.PostApplicationRequest))
Expect(actualParams.RequestName).To(Equal(ccv3internal.PostApplicationRequest))
Expect(actualParams.RequestBody).To(Equal(appToCreate))
_, ok := actualParams.ResponseBody.(*resources.Application)
Expect(ok).To(BeTrue())
Expand Down Expand Up @@ -365,7 +366,7 @@ var _ = Describe("Application", func() {
It("makes the correct request", func() {
Expect(requester.MakeListRequestCallCount()).To(Equal(1))
actualParams := requester.MakeListRequestArgsForCall(0)
Expect(actualParams.RequestName).To(Equal(internal.GetApplicationsRequest))
Expect(actualParams.RequestName).To(Equal(ccv3internal.GetApplicationsRequest))
Expect(actualParams.Query).To(Equal([]Query{
{Key: NameFilter, Values: []string{"some-app-name"}},
{Key: SpaceGUIDFilter, Values: []string{"some-space-guid"}},
Expand Down Expand Up @@ -467,7 +468,7 @@ var _ = Describe("Application", func() {
It("makes the correct request", func() {
Expect(requester.MakeListRequestCallCount()).To(Equal(1))
actualParams := requester.MakeListRequestArgsForCall(0)
Expect(actualParams.RequestName).To(Equal(internal.GetApplicationsRequest))
Expect(actualParams.RequestName).To(Equal(ccv3internal.GetApplicationsRequest))
Expect(actualParams.Query).To(Equal(filters))
_, ok := actualParams.ResponseBody.(resources.Application)
Expect(ok).To(BeTrue())
Expand Down Expand Up @@ -562,7 +563,7 @@ var _ = Describe("Application", func() {
It("makes the correct request", func() {
Expect(requester.MakeRequestCallCount()).To(Equal(1))
actualParams := requester.MakeRequestArgsForCall(0)
Expect(actualParams.RequestName).To(Equal(internal.PatchApplicationRequest))
Expect(actualParams.RequestName).To(Equal(ccv3internal.PatchApplicationRequest))
Expect(actualParams.URIParams).To(Equal(internal.Params{"app_guid": "some-app-guid"}))
Expect(actualParams.RequestBody).To(Equal(appToUpdate))
_, ok := actualParams.ResponseBody.(*resources.Application)
Expand Down Expand Up @@ -660,7 +661,7 @@ var _ = Describe("Application", func() {
It("makes the correct request", func() {
Expect(requester.MakeRequestCallCount()).To(Equal(1))
actualParams := requester.MakeRequestArgsForCall(0)
Expect(actualParams.RequestName).To(Equal(internal.PatchApplicationRequest))
Expect(actualParams.RequestName).To(Equal(ccv3internal.PatchApplicationRequest))
Expect(actualParams.URIParams).To(Equal(internal.Params{"app_guid": "some-app-guid"}))
Expect(actualParams.RequestBody).To(Equal(resources.ApplicationNameOnly{Name: newAppName}))
_, ok := actualParams.ResponseBody.(*resources.Application)
Expand Down Expand Up @@ -749,7 +750,7 @@ var _ = Describe("Application", func() {
It("makes the correct request", func() {
Expect(requester.MakeRequestCallCount()).To(Equal(1))
actualParams := requester.MakeRequestArgsForCall(0)
Expect(actualParams.RequestName).To(Equal(internal.PostApplicationActionStopRequest))
Expect(actualParams.RequestName).To(Equal(ccv3internal.PostApplicationActionStopRequest))
Expect(actualParams.URIParams).To(Equal(internal.Params{"app_guid": "some-app-guid"}))
_, ok := actualParams.ResponseBody.(*resources.Application)
Expect(ok).To(BeTrue())
Expand Down Expand Up @@ -832,7 +833,7 @@ var _ = Describe("Application", func() {
It("makes the correct request", func() {
Expect(requester.MakeRequestCallCount()).To(Equal(1))
actualParams := requester.MakeRequestArgsForCall(0)
Expect(actualParams.RequestName).To(Equal(internal.PostApplicationActionStartRequest))
Expect(actualParams.RequestName).To(Equal(ccv3internal.PostApplicationActionStartRequest))
Expect(actualParams.URIParams).To(Equal(internal.Params{"app_guid": "some-app-guid"}))
_, ok := actualParams.ResponseBody.(*resources.Application)
Expect(ok).To(BeTrue())
Expand Down Expand Up @@ -915,7 +916,7 @@ var _ = Describe("Application", func() {
It("makes the correct request", func() {
Expect(requester.MakeRequestCallCount()).To(Equal(1))
actualParams := requester.MakeRequestArgsForCall(0)
Expect(actualParams.RequestName).To(Equal(internal.PostApplicationActionRestartRequest))
Expect(actualParams.RequestName).To(Equal(ccv3internal.PostApplicationActionRestartRequest))
Expect(actualParams.URIParams).To(Equal(internal.Params{"app_guid": "some-app-guid"}))
_, ok := actualParams.ResponseBody.(*resources.Application)
Expect(ok).To(BeTrue())
Expand Down
7 changes: 4 additions & 3 deletions api/cloudcontroller/ccv3/build.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package ccv3

import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
apiinternal "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
"code.cloudfoundry.org/cli/api/internal"
"code.cloudfoundry.org/cli/resources"
)

Expand All @@ -11,7 +12,7 @@ func (client *Client) CreateBuild(build resources.Build) (resources.Build, Warni
var responseBody resources.Build

_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PostBuildRequest,
RequestName: apiinternal.PostBuildRequest,
RequestBody: build,
ResponseBody: &responseBody,
})
Expand All @@ -24,7 +25,7 @@ func (client *Client) GetBuild(guid string) (resources.Build, Warnings, error) {
var responseBody resources.Build

_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.GetBuildRequest,
RequestName: apiinternal.GetBuildRequest,
URIParams: internal.Params{"build_guid": guid},
ResponseBody: &responseBody,
})
Expand Down
13 changes: 7 additions & 6 deletions api/cloudcontroller/ccv3/buildpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package ccv3
import (
"io"

"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
ccv3internal "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
"code.cloudfoundry.org/cli/api/cloudcontroller/uploads"
"code.cloudfoundry.org/cli/api/internal"
"code.cloudfoundry.org/cli/resources"
)

Expand All @@ -14,7 +15,7 @@ func (client *Client) CreateBuildpack(bp resources.Buildpack) (resources.Buildpa
var responseBody resources.Buildpack

_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PostBuildpackRequest,
RequestName: ccv3internal.PostBuildpackRequest,
RequestBody: bp,
ResponseBody: &responseBody,
})
Expand All @@ -25,7 +26,7 @@ func (client *Client) CreateBuildpack(bp resources.Buildpack) (resources.Buildpa
// DeleteBuildpack deletes the buildpack with the provided guid.
func (client Client) DeleteBuildpack(buildpackGUID string) (JobURL, Warnings, error) {
jobURL, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.DeleteBuildpackRequest,
RequestName: ccv3internal.DeleteBuildpackRequest,
URIParams: internal.Params{"buildpack_guid": buildpackGUID},
})

Expand All @@ -37,7 +38,7 @@ func (client *Client) GetBuildpacks(query ...Query) ([]resources.Buildpack, Warn
var buildpacks []resources.Buildpack

_, warnings, err := client.MakeListRequest(RequestParams{
RequestName: internal.GetBuildpacksRequest,
RequestName: ccv3internal.GetBuildpacksRequest,
Query: query,
ResponseBody: resources.Buildpack{},
AppendToList: func(item interface{}) error {
Expand All @@ -53,7 +54,7 @@ func (client Client) UpdateBuildpack(buildpack resources.Buildpack) (resources.B
var responseBody resources.Buildpack

_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PatchBuildpackRequest,
RequestName: ccv3internal.PatchBuildpackRequest,
URIParams: internal.Params{"buildpack_guid": buildpack.GUID},
RequestBody: buildpack,
ResponseBody: &responseBody,
Expand All @@ -73,7 +74,7 @@ func (client *Client) UploadBuildpack(buildpackGUID string, buildpackPath string
contentType, body, writeErrors := uploads.CreateMultipartBodyAndHeader(buildpack, buildpackPath, "bits")

responseLocation, warnings, err := client.MakeRequestUploadAsync(
internal.PostBuildpackBitsRequest,
ccv3internal.PostBuildpackBitsRequest,
internal.Params{"buildpack_guid": buildpackGUID},
contentType,
body,
Expand Down
7 changes: 4 additions & 3 deletions api/cloudcontroller/ccv3/ccv3fakes/fake_clock.go

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

14 changes: 8 additions & 6 deletions api/cloudcontroller/ccv3/ccv3fakes/fake_connection_wrapper.go

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

7 changes: 4 additions & 3 deletions api/cloudcontroller/ccv3/ccv3fakes/fake_reader.go

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

Loading

0 comments on commit aa1a29f

Please sign in to comment.