Skip to content

Commit

Permalink
Add MinVersionPerRouteOpts check for create and update route commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariquest committed Dec 19, 2024
1 parent 389518f commit 02fb611
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cf/commands/route/create_route.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package route

import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccversion"
"code.cloudfoundry.org/cli/cf/api"
"code.cloudfoundry.org/cli/cf/commandregistry"
"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
Expand All @@ -9,6 +10,7 @@ import (
"code.cloudfoundry.org/cli/cf/models"
"code.cloudfoundry.org/cli/cf/requirements"
"code.cloudfoundry.org/cli/cf/terminal"
"code.cloudfoundry.org/cli/command"
"fmt"
)

Expand Down Expand Up @@ -112,6 +114,17 @@ func (cmd *CreateRoute) Execute(c flags.FlagContext) error {
port := c.Int("port")
randomPort := c.Bool("random-port")
option := c.String("o")

if option != "" {
err := command.MinimumCCAPIVersionCheck(cmd.config.APIVersion(), ccversion.MinVersionPerRouteOpts)
if err != nil {
cmd.ui.Say(T("Your CC API version ({{.APIVersion}}) does not support per route options."+
"Upgrade to a newer version of the API (minimum version {{.MinSupportedVersion}}). ", map[string]interface{}{
"APIVersion": cmd.config.APIVersion(),
"MinSupportedVersion": ccversion.MinVersionPerRouteOpts,
}))
}
}
_, err := cmd.CreateRoute(hostName, path, port, randomPort, domain, space.SpaceFields, option)
if err != nil {
return err
Expand Down
11 changes: 11 additions & 0 deletions cf/commands/route/update_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ func (cmd *UpdateRoute) Execute(c flags.FlagContext) error {
removeOption := c.String("r")
port := 0

if option != "" {
err := command.MinimumCCAPIVersionCheck(cmd.config.APIVersion(), ccversion.MinVersionPerRouteOpts)
if err != nil {
cmd.ui.Say(T("Your CC API version ({{.APIVersion}}) does not support per route options."+
"Upgrade to a newer version of the API (minimum version {{.MinSupportedVersion}}). ", map[string]interface{}{
"APIVersion": cmd.config.APIVersion(),
"MinSupportedVersion": ccversion.MinVersionPerRouteOpts,
}))
}
}

url := (&models.RoutePresenter{
Host: host,
Domain: domain,
Expand Down

0 comments on commit 02fb611

Please sign in to comment.