-
Notifications
You must be signed in to change notification settings - Fork 67
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
Add new astro cli commands to support RBAC in Orbit #214
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8c3682d
Add fake astro workspace user list
andriisoldatenko 0979517
Add fake WorkspaceUserListRolesRequest
andriisoldatenko 0e07e2f
Add astro workspace user list
andriisoldatenko dbd5e17
Add add user with role to workspace
andriisoldatenko 0f394f1
Add Update Role
andriisoldatenko 84a30b0
Improve message text's
andriisoldatenko 9339613
remove unused comment
andriisoldatenko f1f2c65
.
andriisoldatenko File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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 |
---|---|---|
|
@@ -80,6 +80,14 @@ var ( | |
RunE: workspaceUserAdd, | ||
} | ||
|
||
workspaceUserUpdateCmd = &cobra.Command{ | ||
Use: "update user role", | ||
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. @schnie ^ 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. looks good |
||
Short: "Update a user's role for a workspace", | ||
Long: "Update a user's role for a workspace", | ||
Args: cobra.ExactArgs(1), | ||
RunE: workspaceUserUpdate, | ||
} | ||
|
||
workspaceUserRmCmd = &cobra.Command{ | ||
Use: "remove EMAIL", | ||
Aliases: []string{"rm"}, | ||
|
@@ -88,6 +96,13 @@ var ( | |
Args: cobra.ExactArgs(1), | ||
RunE: workspaceUserRm, | ||
} | ||
|
||
workspaceUserListCmd = &cobra.Command{ | ||
Use: "list", | ||
Short: "List users in a workspace", | ||
Long: "List users in a workspace", | ||
RunE: workspaceUserList, | ||
} | ||
) | ||
|
||
func init() { | ||
|
@@ -116,10 +131,18 @@ func init() { | |
// workspace user add | ||
workspaceUserRootCmd.AddCommand(workspaceUserAddCmd) | ||
workspaceUserAddCmd.PersistentFlags().StringVar(&workspaceId, "workspace-id", "", "workspace assigned to deployment") | ||
workspaceUserAddCmd.PersistentFlags().StringVar(&role, "role", "WORKSPACE_VIEWER", "role assigned to user") | ||
|
||
// workspace user update | ||
workspaceUserRootCmd.AddCommand(workspaceUserUpdateCmd) | ||
workspaceUserUpdateCmd.PersistentFlags().StringVar(&role, "role", "WORKSPACE_VIEWER", "role assigned to user") | ||
|
||
// workspace user remove | ||
workspaceUserRootCmd.AddCommand(workspaceUserRmCmd) | ||
workspaceUserRmCmd.PersistentFlags().StringVar(&workspaceId, "workspace-id", "", "workspace assigned to deployment") | ||
|
||
// workspace user list | ||
workspaceUserRootCmd.AddCommand(workspaceUserListCmd) | ||
} | ||
|
||
func workspaceCreate(cmd *cobra.Command, args []string) error { | ||
|
@@ -163,13 +186,30 @@ func workspaceUserAdd(cmd *cobra.Command, args []string) error { | |
ws, err := coalesceWorkspace() | ||
if err != nil { | ||
return errors.Wrap(err, "failed to find a valid workspace") | ||
// fmt.Println("Default workspace id not set, set default workspace id or pass a workspace in via the --workspace-id flag") | ||
} | ||
|
||
if err := validateRole(role); err != nil { | ||
return errors.Wrap(err, "failed to find a valid role") | ||
} | ||
|
||
// Silence Usage as we have now validated command input | ||
cmd.SilenceUsage = true | ||
return workspace.Add(ws, args[0], role) | ||
} | ||
|
||
func workspaceUserUpdate(cmd *cobra.Command, args []string) error { | ||
ws, err := coalesceWorkspace() | ||
if err != nil { | ||
return errors.Wrap(err, "failed to find a valid workspace") | ||
} | ||
|
||
return workspace.Add(ws, args[0]) | ||
if err := validateRole(role); err != nil { | ||
return errors.Wrap(err, "failed to find a valid role") | ||
} | ||
|
||
// Silence Usage as we have now validated command input | ||
cmd.SilenceUsage = true | ||
return workspace.UpdateRole(ws, args[0], role) | ||
} | ||
|
||
func workspaceUserRm(cmd *cobra.Command, args []string) error { | ||
|
@@ -197,3 +237,11 @@ func workspaceSwitch(cmd *cobra.Command, args []string) error { | |
|
||
return workspace.Switch(id) | ||
} | ||
|
||
func workspaceUserList(cmd *cobra.Command, args []string) error { | ||
ws, err := coalesceWorkspace() | ||
if err != nil { | ||
return errors.Wrap(err, "failed to find a valid workspace") | ||
} | ||
return workspace.ListRoles(ws) | ||
} |
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
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.
@schnie Please take a look on error message? sounds good?
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.
looks fine to me