-
Notifications
You must be signed in to change notification settings - Fork 26
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
adding needed flags to impersonate #49
Conversation
Codecov Report
@@ Coverage Diff @@
## master #49 +/- ##
=======================================
Coverage 86.00% 86.00%
=======================================
Files 5 5
Lines 343 343
=======================================
Hits 295 295
Misses 25 25
Partials 23 23
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -80,4 +85,6 @@ func init() { | |||
rootCmd.AddCommand(getCmd) | |||
getCmd.Flags().StringVar(&getArgs.KubeconfigPath, "kubeconfig", "", "Path to kubeconfig") | |||
getCmd.Flags().StringVar(&getArgs.Format, "format", "table", "The format in which to display results (currently only 'table' supported)") | |||
getCmd.Flags().StringVar(&upsertArgs.AsUser, "as", "", "Username to impersonate for the operation") |
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.
Wondering if these flags can be rootCmd flags and carry over to all commands as a result
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 had them initially as root but then they show up in version -h
if your fine with that more then happy to change it
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.
Good point - thats fine, lets leave as is then
@@ -80,4 +85,6 @@ func init() { | |||
rootCmd.AddCommand(getCmd) | |||
getCmd.Flags().StringVar(&getArgs.KubeconfigPath, "kubeconfig", "", "Path to kubeconfig") | |||
getCmd.Flags().StringVar(&getArgs.Format, "format", "table", "The format in which to display results (currently only 'table' supported)") | |||
getCmd.Flags().StringVar(&upsertArgs.AsUser, "as", "", "Username to impersonate for the operation") | |||
getCmd.Flags().StringSliceVar(&upsertArgs.AsGroups, "as-group", []string{}, "Group to impersonate for the operation, this flag can be repeated to specify multiple groups") |
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.
Will a comma separated list work in this case as well? if thats the case description can just say "List of groups to impersonate..."
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 believe so ill write a test to validate. I pulled the wording directly from kubectl
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.
@eytan-avisror actually not sure off hand how to write a test for this, there isnt anything in place in the tests where the cli is being called. this works though
go run main.go upsert --as me --as-group "system:masters" --as-group "sudoers" --maproles --rolearn arn:aws:iam::xxxxxxxxxxxxxxxx:role/test_team --append --groups testing --username foo --update-username=false
role arn:aws:iam::xxxxxxxxxxxxxxxx:role/test_team has been updated
@@ -75,6 +80,9 @@ func getKubernetesClient(kubePath string) (kubernetes.Interface, error) { | |||
} | |||
} | |||
|
|||
config.Impersonate.UserName = options.AsUser | |||
config.Impersonate.Groups = options.AsGroups | |||
|
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.
Can you elaborate more on the use-case for being able to impersonate in the case of modifying aws-auth?
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.
this allows the ability to not have to hardcode --as
and --as-group
values in the kube config.
Thanks @45cali 👍 |
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.
LGTM, you need to sign the commits to address the DCO
Signed-off-by: Nicholas Colbert <[email protected]>
Signed-off-by: Nicholas Colbert <[email protected]>
5bcfb25
to
8f1b0ef
Compare
this pull request provides the needed flags to impersonate when using the
get
,upsert
andremove
commands--as
--as-user