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

RFC0027 CLI Support for Generic Per-Route Options [main] #3372

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3a97bc6
New command help
Dariquest Jan 21, 2025
7d13cab
Update-, create-, map-route, route, routes, app, apps
Dariquest Jan 21, 2025
35eb328
Missing imports
Dariquest Jan 21, 2025
274e81d
Generate fakes and two unit tests corrections
Dariquest Jan 22, 2025
d85deb4
Fix unit test json
Dariquest Jan 22, 2025
e4d93e3
Fix unit test json
Dariquest Jan 22, 2025
20b3ada
Fix lint errors
Dariquest Jan 23, 2025
59790ce
Remove unnecessary fakes
Dariquest Jan 23, 2025
cd68acd
Merge branch 'main' into updateRouteCommandsMain
Dariquest Jan 24, 2025
967ed16
Review changes
Dariquest Jan 27, 2025
059760a
Review changes units
Dariquest Jan 27, 2025
577a3af
Change DisplayText to DisplayWarning for flag spec err
Dariquest Jan 28, 2025
917e74b
Output an error if at least one option is specified incorrectly
Dariquest Jan 28, 2025
7be6622
Output an error if at least one option is specified incorrectly
Dariquest Jan 28, 2025
041b352
Merge branch 'main' into updateRouteCommandsMain
Dariquest Jan 29, 2025
3e1d55e
Fix helper
Dariquest Jan 29, 2025
5be9eba
Fix helper - remove a route option
Dariquest Jan 30, 2025
3faf27d
New integration test and adjustments of other tests
Dariquest Jan 30, 2025
4203b9f
Fix integration tests
Dariquest Jan 30, 2025
b575fde
Fix integration tests
Dariquest Jan 30, 2025
6f31f75
Fix integration tests
Dariquest Jan 31, 2025
1e90e4b
Merge branch 'main' into updateRouteCommandsMain
Dariquest Jan 31, 2025
db0abfa
Consistent naming: per-route options vs route specific options
Dariquest Jan 31, 2025
7e74a2c
Las integration test corrections
Dariquest Jan 31, 2025
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
1 change: 1 addition & 0 deletions actor/v7action/cloud_controller_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ type CloudControllerClient interface {
UpdateOrganizationQuota(orgQuota resources.OrganizationQuota) (resources.OrganizationQuota, ccv3.Warnings, error)
UpdateProcess(process resources.Process) (resources.Process, ccv3.Warnings, error)
UpdateResourceMetadata(resource string, resourceGUID string, metadata resources.Metadata) (ccv3.JobURL, ccv3.Warnings, error)
UpdateRoute(routeGUID string, options map[string]*string) (resources.Route, ccv3.Warnings, error)
UpdateSecurityGroupRunningSpace(securityGroupGUID string, spaceGUIDs []string) (ccv3.Warnings, error)
UpdateSecurityGroupStagingSpace(securityGroupGUID string, spaceGUIDs []string) (ccv3.Warnings, error)
UpdateSecurityGroup(securityGroup resources.SecurityGroup) (resources.SecurityGroup, ccv3.Warnings, error)
Expand Down
8 changes: 7 additions & 1 deletion actor/v7action/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type RouteSummary struct {
ServiceInstanceName string
}

func (actor Actor) CreateRoute(spaceGUID, domainName, hostname, path string, port int) (resources.Route, Warnings, error) {
func (actor Actor) CreateRoute(spaceGUID, domainName, hostname, path string, port int, options map[string]*string) (resources.Route, Warnings, error) {
allWarnings := Warnings{}
domain, warnings, err := actor.GetDomainByName(domainName)
allWarnings = append(allWarnings, warnings...)
Expand All @@ -41,6 +41,7 @@ func (actor Actor) CreateRoute(spaceGUID, domainName, hostname, path string, por
Host: hostname,
Path: path,
Port: port,
Options: options,
})

actorWarnings := Warnings(apiWarnings)
Expand Down Expand Up @@ -401,6 +402,11 @@ func (actor Actor) MapRoute(routeGUID string, appGUID string, destinationProtoco
return Warnings(warnings), err
}

func (actor Actor) UpdateRoute(routeGUID string, options map[string]*string) (resources.Route, Warnings, error) {
route, warnings, err := actor.CloudControllerClient.UpdateRoute(routeGUID, options)
return route, Warnings(warnings), err
}

func (actor Actor) UpdateDestination(routeGUID string, destinationGUID string, protocol string) (Warnings, error) {
warnings, err := actor.CloudControllerClient.UpdateDestination(routeGUID, destinationGUID, protocol)
return Warnings(warnings), err
Expand Down
10 changes: 8 additions & 2 deletions actor/v7action/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@ var _ = Describe("Route Actions", func() {
hostname string
path string
port int
options map[string]*string
)

BeforeEach(func() {
hostname = ""
path = ""
port = 0
lbLCVal := "least-connections"
lbLeastConnections := &lbLCVal
options = map[string]*string{"loadbalancing": lbLeastConnections}
})

JustBeforeEach(func() {
_, warnings, executeErr = actor.CreateRoute("space-guid", "domain-name", hostname, path, port)
_, warnings, executeErr = actor.CreateRoute("space-guid", "domain-name", hostname, path, port, options)
})

When("the API layer calls are successful", func() {
Expand All @@ -56,7 +60,7 @@ var _ = Describe("Route Actions", func() {
)

fakeCloudControllerClient.CreateRouteReturns(
resources.Route{GUID: "route-guid", SpaceGUID: "space-guid", DomainGUID: "domain-guid", Host: "hostname", Path: "path-name"},
resources.Route{GUID: "route-guid", SpaceGUID: "space-guid", DomainGUID: "domain-guid", Host: "hostname", Path: "path-name", Options: options},
ccv3.Warnings{"create-warning-1", "create-warning-2"},
nil)
})
Expand All @@ -80,6 +84,7 @@ var _ = Describe("Route Actions", func() {
DomainGUID: "domain-guid",
Host: hostname,
Path: path,
Options: options,
},
))
})
Expand All @@ -102,6 +107,7 @@ var _ = Describe("Route Actions", func() {
SpaceGUID: "space-guid",
DomainGUID: "domain-guid",
Port: 1234,
Options: options,
},
))
})
Expand Down
86 changes: 86 additions & 0 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.

3 changes: 2 additions & 1 deletion actor/v7pushaction/v7_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type V7Actor interface {
CreateBitsPackageByApplication(appGUID string) (resources.Package, v7action.Warnings, error)
CreateDeployment(dep resources.Deployment) (string, v7action.Warnings, error)
CreateDockerPackageByApplication(appGUID string, dockerImageCredentials v7action.DockerImageCredentials) (resources.Package, v7action.Warnings, error)
CreateRoute(spaceGUID, domainName, hostname, path string, port int) (resources.Route, v7action.Warnings, error)
CreateRoute(spaceGUID, domainName, hostname, path string, port int, options map[string]*string) (resources.Route, v7action.Warnings, error)
GetApplicationByNameAndSpace(appName string, spaceGUID string) (resources.Application, v7action.Warnings, error)
GetApplicationDroplets(appName string, spaceGUID string) ([]resources.Droplet, v7action.Warnings, error)
GetApplicationRoutes(appGUID string) ([]resources.Route, v7action.Warnings, error)
Expand All @@ -41,6 +41,7 @@ type V7Actor interface {
UnmapRoute(routeGUID string, destinationGUID string) (v7action.Warnings, error)
UpdateApplication(app resources.Application) (resources.Application, v7action.Warnings, error)
UpdateProcessByTypeAndApplication(processType string, appGUID string, updatedProcess resources.Process) (v7action.Warnings, error)
UpdateRoute(routeGUID string, options map[string]*string) (resources.Route, v7action.Warnings, error)
UploadBitsPackage(pkg resources.Package, matchedResources []sharedaction.V3Resource, newResources io.Reader, newResourcesLength int64) (resources.Package, v7action.Warnings, error)
UploadDroplet(dropletGUID string, dropletPath string, progressReader io.Reader, fileSize int64) (v7action.Warnings, error)
}
104 changes: 96 additions & 8 deletions actor/v7pushaction/v7pushactionfakes/fake_v7actor.go

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

2 changes: 2 additions & 0 deletions api/cloudcontroller/ccv3/internal/api_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const (
GetUserRequest = "GetUser"
GetUsersRequest = "GetUsers"
MapRouteRequest = "MapRoute"
UpdateRouteRequest = "UpdateRoute"
PatchApplicationCurrentDropletRequest = "PatchApplicationCurrentDroplet"
PatchApplicationEnvironmentVariablesRequest = "PatchApplicationEnvironmentVariables"
PatchApplicationRequest = "PatchApplication"
Expand Down Expand Up @@ -281,6 +282,7 @@ var APIRoutes = map[string]Route{
PatchRouteRequest: {Path: "/v3/routes/:route_guid", Method: http.MethodPatch},
GetRouteDestinationsRequest: {Path: "/v3/routes/:route_guid/destinations", Method: http.MethodGet},
MapRouteRequest: {Path: "/v3/routes/:route_guid/destinations", Method: http.MethodPost},
UpdateRouteRequest: {Path: "/v3/routes/:route_guid", Method: http.MethodPatch},
UnmapRouteRequest: {Path: "/v3/routes/:route_guid/destinations/:destination_guid", Method: http.MethodDelete},
PatchDestinationRequest: {Path: "/v3/routes/:route_guid/destinations/:destination_guid", Method: http.MethodPatch},
ShareRouteRequest: {Path: "/v3/routes/:route_guid/relationships/shared_spaces", Method: http.MethodPost},
Expand Down
Loading
Loading