-
Notifications
You must be signed in to change notification settings - Fork 928
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
feat: Add move-route command to cf cli #2302
Merged
Merged
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
36005f0
feat: Add transfer-route-owner command to cf cli
PeteLevineA 5442027
feat: update repository variable. Update workflow action
PeteLevineA ca0f9be
fix: remove windows 2016, swap to windows latest. Fix relative file path
PeteLevineA 6d48c00
chore: windows values
PeteLevineA be55f94
chore: swap to Rel instead of join
PeteLevineA d1873ce
chore: main dir
PeteLevineA 079e566
chore: join on current dir
PeteLevineA a45d87e
chore: clean path first
PeteLevineA 541dc83
chore: try from slash
PeteLevineA 4c045fd
chore: remove dot syntax
PeteLevineA 4fb4032
chore: swap to move-route
PeteLevineA 6391cf4
chore: windows tests again
PeteLevineA c86f7a2
chore: remove test println
PeteLevineA 9ffed43
chore: update path to /relationships/space from transferowner
PeteLevineA f89c8d5
Change display text
gururajsh 09dd1b5
Remove focus
gururajsh 63b8fec
Fix typo
gururajsh 532b1e4
Send non-array data in requestBody
gururajsh 7b72668
Change message ordering
gururajsh 0e61545
Create shared domain instead of private
gururajsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
name: Units Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
|
||
on: [push] | ||
permissions: | ||
contents: write | ||
|
||
|
@@ -83,9 +79,8 @@ jobs: | |
strategy: | ||
matrix: | ||
os: | ||
- windows-2022 | ||
- windows-latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious why we unlocked this. |
||
- windows-2019 | ||
- windows-2016 | ||
runs-on: ${{ matrix.os }} | ||
needs: shared-values | ||
defaults: | ||
|
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"` | ||
DestinationSpace string `short:"s" description:"The space of the destination app (Default: targeted space)"` | ||
DestinationOrg string `short:"o" description:"The org of the destination app (Default: targeted org)"` | ||
|
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer having GitHub Actions related changes in a separate PR, so we can easily synchronize these changes with other branches.