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 [v8] #3366

Open
wants to merge 26 commits into
base: v8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
aedcad5
Running unit tests version
Dariquest Dec 19, 2024
c262724
Running unit tests version
Dariquest Dec 19, 2024
0105e89
Add MinVersionPerRouteOpts
Dariquest Dec 19, 2024
7ed07ef
Add MinVersionPerRouteOpts check for create and update route commands
Dariquest Dec 19, 2024
db8cf87
Remove double check
Dariquest Jan 9, 2025
e3e288d
Refactoring
Dariquest Jan 9, 2025
5c93571
New unit tests for route option removal
Dariquest Jan 9, 2025
95cb4be
New unit tests for route option removal
Dariquest Jan 9, 2025
bbe4c63
New unit tests for multiple option handling
Dariquest Jan 9, 2025
eb9f03d
Route command in the v7/commands
Dariquest Jan 17, 2025
a175b57
Fix ccv3 route test
Dariquest Jan 17, 2025
c06d0f0
Fix units
Dariquest Jan 17, 2025
a21a452
Changed typed route options to an untyped map
Dariquest Jan 20, 2025
177dab7
Merge branch 'v8' into updateRouteCommands
Dariquest Jan 20, 2025
38b8fe8
Removing all the changes in cf/commands
Dariquest Jan 20, 2025
60eec2e
Removing all the changes in cf/commands
Dariquest Jan 20, 2025
68b21eb
Removing a duplicate line
Dariquest Jan 21, 2025
08df90c
Fix linter issues
hoffmaen Jan 23, 2025
0874b29
Restore unnecessary fakes
Dariquest Jan 23, 2025
795034d
Restore non relevant fakes
Dariquest Jan 23, 2025
980e156
Restore non relevant fakes
Dariquest Jan 23, 2025
dbc34d7
Restore non relevant fakes
Dariquest Jan 23, 2025
d3a38bc
Refactoring
Dariquest Jan 23, 2025
7991003
Merge branch 'v8' into updateRouteCommands
Dariquest Jan 24, 2025
2f55a61
Review changes
Dariquest Jan 27, 2025
8e0e6da
Review changes units
Dariquest Jan 27, 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 @@ -179,6 +179,7 @@ const (
ShareRouteRequest = "ShareRouteRequest"
UnmapRouteRequest = "UnmapRoute"
UnshareRouteRequest = "UnshareRoute"
UpdateRouteRequest = "UpdateRoute"
WhoAmI = "WhoAmI"
)

Expand Down Expand Up @@ -282,6 +283,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