-
Notifications
You must be signed in to change notification settings - Fork 66
feat(acl list): add flags to filter by resource #1299
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f075e62
feat(acl list): add flags to filter by resource
rkpattnaik780 d3561db
docs: update acl list docs
rkpattnaik780 4abc138
docs: add flag examples
rkpattnaik780 3afabd0
fix: address review comments
rkpattnaik780 b3fcf0f
fix: address review comments
rkpattnaik780 f2c902f
refactor: add autocompletions, change struct defs
rkpattnaik780 e292865
fix: change help texts
rkpattnaik780 bdd57bf
fix: remove localizer from flagset constructor
rkpattnaik780 e3313cf
fix: remove unused i18n key
rkpattnaik780 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -23,19 +23,17 @@ var ResourceTypeFlagEntries []*localize.TemplateEntry = []*localize.TemplateEntr | |
| } | ||
|
|
||
| type flagSet struct { | ||
| cmd *cobra.Command | ||
| localizer localize.Localizer | ||
| conn factory.ConnectionFunc | ||
| cmd *cobra.Command | ||
| factory *factory.Factory | ||
| *flagutil.FlagSet | ||
| } | ||
|
|
||
| // NewFlagSet returns a new flag set with common Kafka ACL flags | ||
| func NewFlagSet(cmd *cobra.Command, localizer localize.Localizer, conn factory.ConnectionFunc) *flagSet { | ||
| func NewFlagSet(cmd *cobra.Command, localizer localize.Localizer, f *factory.Factory) *flagSet { | ||
| return &flagSet{ | ||
| cmd: cmd, | ||
| localizer: localizer, | ||
| conn: conn, | ||
| FlagSet: flagutil.NewFlagSet(cmd, localizer), | ||
| cmd: cmd, | ||
| factory: f, | ||
| FlagSet: flagutil.NewFlagSet(cmd, localizer), | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -54,7 +52,7 @@ func (fs *flagSet) AddResourceType(resourceType *string) *flagutil.FlagOptions { | |
| resourceType, | ||
| flagName, | ||
| aclutil.ResourceTypeANY, | ||
| flagutil.FlagDescription(fs.localizer, "kafka.acl.common.flag.resourceType", resourceTypes...), | ||
| flagutil.FlagDescription(fs.factory.Localizer, "kafka.acl.common.flag.resourceType", resourceTypes...), | ||
| ) | ||
|
|
||
| _ = fs.cmd.RegisterFlagCompletionFunc(flagName, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
|
|
@@ -79,7 +77,7 @@ func (fs *flagSet) AddOperationFilter(operationType *string) *flagutil.FlagOptio | |
| operationType, | ||
| flagName, | ||
| "", | ||
| flagutil.FlagDescription(fs.localizer, "kafka.acl.common.flag.operation.description", operations...), | ||
| flagutil.FlagDescription(fs.factory.Localizer, "kafka.acl.common.flag.operation.description", operations...), | ||
| ) | ||
|
|
||
| _ = fs.cmd.RegisterFlagCompletionFunc(flagName, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
|
|
@@ -104,7 +102,7 @@ func (fs *flagSet) AddOperationCreate(operationType *string) *flagutil.FlagOptio | |
| operationType, | ||
| flagName, | ||
| "", | ||
| flagutil.FlagDescription(fs.localizer, "kafka.acl.common.flag.operation.description", operations...), | ||
| flagutil.FlagDescription(fs.factory.Localizer, "kafka.acl.common.flag.operation.description", operations...), | ||
| ) | ||
|
|
||
| _ = fs.cmd.RegisterFlagCompletionFunc(flagName, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
|
|
@@ -129,7 +127,7 @@ func (fs *flagSet) AddPermissionFilter(permission *string) *flagutil.FlagOptions | |
| permission, | ||
| flagName, | ||
| aclutil.PermissionANY, | ||
| flagutil.FlagDescription(fs.localizer, "kafka.acl.common.flag.permission.description", permissions...), | ||
| flagutil.FlagDescription(fs.factory.Localizer, "kafka.acl.common.flag.permission.description", permissions...), | ||
| ) | ||
|
|
||
| _ = fs.cmd.RegisterFlagCompletionFunc(flagName, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
|
|
@@ -154,7 +152,7 @@ func (fs *flagSet) AddPermissionCreate(permission *string) *flagutil.FlagOptions | |
| permission, | ||
| flagName, | ||
| "", | ||
| flagutil.FlagDescription(fs.localizer, "kafka.acl.common.flag.permission.description", permissions...), | ||
| flagutil.FlagDescription(fs.factory.Localizer, "kafka.acl.common.flag.permission.description", permissions...), | ||
| ) | ||
|
|
||
| _ = fs.cmd.RegisterFlagCompletionFunc(flagName, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
|
|
@@ -172,8 +170,10 @@ func (fs *flagSet) AddTopic(topic *string) { | |
| topic, | ||
| flagName, | ||
| "", | ||
| fs.localizer.MustLocalize("kafka.acl.common.flag.topic.description"), | ||
| fs.factory.Localizer.MustLocalize("kafka.acl.common.flag.topic.description"), | ||
| ) | ||
|
|
||
| _ = flagutil.RegisterTopicCompletionFunc(fs.cmd, fs.factory) | ||
| } | ||
|
|
||
| // AddConsumerGroup adds a flag for setting the consumer group ID | ||
|
|
@@ -184,8 +184,10 @@ func (fs *flagSet) AddConsumerGroup(group *string) { | |
| group, | ||
| flagName, | ||
| "", | ||
| fs.localizer.MustLocalize("kafka.acl.common.flag.group.description"), | ||
| fs.factory.Localizer.MustLocalize("kafka.acl.common.flag.group.description"), | ||
| ) | ||
|
|
||
| _ = flagutil.RegisterGroupCompletionFunc(fs.cmd, fs.factory) | ||
| } | ||
|
|
||
| // AddTransactionalID adds a flag for setting the consumer group ID | ||
|
|
@@ -196,7 +198,7 @@ func (fs *flagSet) AddTransactionalID(id *string) { | |
| id, | ||
| flagName, | ||
| "", | ||
| fs.localizer.MustLocalize("kafka.acl.common.flag.transactionalID.description"), | ||
| fs.factory.Localizer.MustLocalize("kafka.acl.common.flag.transactionalID.description"), | ||
|
Contributor
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. nit: It may be good to create a local variable to save having to access this nested all the time |
||
| ) | ||
| } | ||
|
|
||
|
|
@@ -208,7 +210,7 @@ func (fs *flagSet) AddPrefix(prefix *bool) { | |
| prefix, | ||
| flagName, | ||
| false, | ||
| fs.localizer.MustLocalize("kafka.acl.common.flag.prefix.description"), | ||
| fs.factory.Localizer.MustLocalize("kafka.acl.common.flag.prefix.description"), | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -220,7 +222,7 @@ func (fs *flagSet) AddCluster(prefix *bool) { | |
| prefix, | ||
| flagName, | ||
| false, | ||
| fs.localizer.MustLocalize("kafka.acl.common.flag.cluster.description"), | ||
| fs.factory.Localizer.MustLocalize("kafka.acl.common.flag.cluster.description"), | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -232,10 +234,10 @@ func (fs *flagSet) AddUser(userID *string) *flagutil.FlagOptions { | |
| userID, | ||
| flagName, | ||
| "", | ||
| fs.localizer.MustLocalize("kafka.acl.common.flag.user.description"), | ||
| fs.factory.Localizer.MustLocalize("kafka.acl.common.flag.user.description"), | ||
| ) | ||
|
|
||
| _ = flagutil.RegisterUserCompletionFunc(fs.cmd, flagName, fs.conn) | ||
| _ = flagutil.RegisterUserCompletionFunc(fs.cmd, flagName, fs.factory) | ||
|
|
||
| return flagutil.WithFlagOptions(fs.cmd, flagName) | ||
| } | ||
|
|
@@ -248,10 +250,10 @@ func (fs *flagSet) AddServiceAccount(serviceAccountID *string) *flagutil.FlagOpt | |
| serviceAccountID, | ||
| flagName, | ||
| "", | ||
| fs.localizer.MustLocalize("kafka.acl.common.flag.serviceAccount.description"), | ||
| fs.factory.Localizer.MustLocalize("kafka.acl.common.flag.serviceAccount.description"), | ||
| ) | ||
|
|
||
| _ = flagutil.RegisterServiceAccountCompletionFunc(fs.cmd, flagName, fs.conn) | ||
| _ = flagutil.RegisterServiceAccountCompletionFunc(fs.cmd, fs.factory) | ||
|
|
||
| return flagutil.WithFlagOptions(fs.cmd, flagName) | ||
| } | ||
|
|
@@ -264,7 +266,7 @@ func (fs *flagSet) AddInstanceID(id *string) { | |
| id, | ||
| flagName, | ||
| "", | ||
| fs.localizer.MustLocalize("kafka.common.flag.instanceID.description"), | ||
| fs.factory.Localizer.MustLocalize("kafka.common.flag.instanceID.description"), | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -276,6 +278,6 @@ func (fs *flagSet) AddAllAccounts(allAccounts *bool) { | |
| allAccounts, | ||
| flagName, | ||
| false, | ||
| fs.localizer.MustLocalize("kafka.acl.common.flag.allAccounts.description"), | ||
| fs.factory.Localizer.MustLocalize("kafka.acl.common.flag.allAccounts.description"), | ||
| ) | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.