-
Notifications
You must be signed in to change notification settings - Fork 928
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: Add transfer-route-owner command to cf cli Co-authored-by: Shwetha Gururaj <[email protected]> * feat: update repository variable. Update workflow action * fix: remove windows 2016, swap to windows latest. Fix relative file path * chore: windows values * chore: swap to Rel instead of join * chore: main dir * chore: join on current dir * chore: clean path first * chore: try from slash * chore: remove dot syntax * chore: swap to move-route Co-authored-by: Shwetha Gururaj <[email protected]> * chore: windows tests again * chore: remove test println * chore: update path to /relationships/space from transferowner Co-authored-by: Shwetha Gururaj <[email protected]> * Change display text * Remove focus * Fix typo * Send non-array data in requestBody * Change message ordering * Create shared domain instead of private Co-authored-by: Shwetha Gururaj <[email protected]> Co-authored-by: Peter Levine <[email protected]>
- Loading branch information
1 parent
6270f99
commit ac80d76
Showing
15 changed files
with
789 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package v7 | ||
|
||
import ( | ||
"code.cloudfoundry.org/cli/actor/actionerror" | ||
"code.cloudfoundry.org/cli/command/flag" | ||
) | ||
|
||
type MoveRouteCommand struct { | ||
BaseCommand | ||
|
||
RequireArgs flag.Domain `positional-args:"yes"` | ||
Hostname string `long:"hostname" short:"n" description:"Hostname for the HTTP route (required for shared domains)"` | ||
Path flag.V7RoutePath `long:"path" description:"Path for the HTTP route"` | ||
DestinationOrg string `short:"o" description:"The org of the destination app (Default: targeted org)"` | ||
DestinationSpace string `short:"s" description:"The space of the destination app (Default: targeted space)"` | ||
|
||
relatedCommands interface{} `related_commands:"create-route, map-route, unmap-route, routes"` | ||
} | ||
|
||
func (cmd MoveRouteCommand) Usage() string { | ||
return ` | ||
Transfers the ownership of a route to a another space: | ||
CF_NAME move-route DOMAIN [--hostname HOSTNAME] [--path PATH] -s OTHER_SPACE [-o OTHER_ORG]` | ||
} | ||
|
||
func (cmd MoveRouteCommand) Examples() string { | ||
return ` | ||
CF_NAME move-route example.com --hostname myHost --path foo -s TargetSpace -o TargetOrg # myhost.example.com/foo | ||
CF_NAME move-route example.com --hostname myHost -s TargetSpace # myhost.example.com | ||
CF_NAME move-route example.com --hostname myHost -s TargetSpace -o TargetOrg # myhost.example.com` | ||
} | ||
|
||
func (cmd MoveRouteCommand) Execute(args []string) error { | ||
err := cmd.SharedActor.CheckTarget(true, true) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
user, err := cmd.Actor.GetCurrentUser() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
domain, warnings, err := cmd.Actor.GetDomainByName(cmd.RequireArgs.Domain) | ||
cmd.UI.DisplayWarnings(warnings) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
path := cmd.Path.Path | ||
route, warnings, err := cmd.Actor.GetRouteByAttributes(domain, cmd.Hostname, path, 0) | ||
cmd.UI.DisplayWarnings(warnings) | ||
if err != nil { | ||
if _, ok := err.(actionerror.RouteNotFoundError); ok { | ||
cmd.UI.DisplayText("Can not transfer ownership of route:") | ||
return err | ||
} | ||
} | ||
|
||
destinationOrgName := cmd.DestinationOrg | ||
|
||
if destinationOrgName == "" { | ||
destinationOrgName = cmd.Config.TargetedOrganizationName() | ||
} | ||
|
||
destinationOrg, warnings, err := cmd.Actor.GetOrganizationByName(destinationOrgName) | ||
|
||
if err != nil { | ||
if _, ok := err.(actionerror.OrganizationNotFoundError); ok { | ||
cmd.UI.DisplayText("Can not transfer ownership of route:") | ||
return err | ||
} | ||
} | ||
|
||
targetedSpace, warnings, err := cmd.Actor.GetSpaceByNameAndOrganization(cmd.DestinationSpace, destinationOrg.GUID) | ||
if err != nil { | ||
if _, ok := err.(actionerror.SpaceNotFoundError); ok { | ||
cmd.UI.DisplayText("Can not transfer ownership of route:") | ||
return err | ||
} | ||
} | ||
|
||
url := desiredURL(domain.Name, cmd.Hostname, path, 0) | ||
cmd.UI.DisplayTextWithFlavor("Move ownership of route {{.URL}} to space {{.DestinationSpace}} as {{.User}}", | ||
map[string]interface{}{ | ||
"URL": url, | ||
"DestinationSpace": cmd.DestinationSpace, | ||
"User": user.Name, | ||
}) | ||
warnings, err = cmd.Actor.MoveRoute( | ||
route.GUID, | ||
targetedSpace.GUID, | ||
) | ||
cmd.UI.DisplayWarnings(warnings) | ||
if err != nil { | ||
return err | ||
} | ||
cmd.UI.DisplayOK() | ||
|
||
return nil | ||
} |
Oops, something went wrong.