Skip to content

feat(acl list): add flags to filter by resource#1299

Merged
rkpattnaik780 merged 9 commits intomainfrom
acl_list_filters
Nov 12, 2021
Merged

feat(acl list): add flags to filter by resource#1299
rkpattnaik780 merged 9 commits intomainfrom
acl_list_filters

Conversation

@rkpattnaik780
Copy link
Contributor

User should be able to list the ACLs per Cluster, Topic or Group.
A small bug fix to ACL list

Verification Steps

  1. Run the command to list permissions for all accounts for topic topic_name
./rhoas kafka acl list --all-accounts --topic kakashi 
  1. Run the command to show all permssions pertaining to group "console-consumer"
./rhoas kafka acl list --group console-consumer

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change
  • Other (please specify)

Checklist

  • Documentation added for the feature
  • CI and all relevant tests are passing
  • Code Review completed
  • Verified independently by reviewer

@wtrocki
Copy link
Collaborator

wtrocki commented Nov 8, 2021

Verified/Reviewed. Changes look good. Pinging @craicoverflow as another SME for correctness

Copy link
Contributor

@craicoverflow craicoverflow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes needed. Left a comment regarding whether --cluster is needed.

Comment on lines +125 to +126
flags.AddTopic(&opts.topic)
flags.AddConsumerGroup(&opts.group)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add dynamic completions for these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be good to add an additional field factory in the flagSet struct? That will make it easier to reuse completions for topic and group from cmdutils?

Copy link
Contributor

@craicoverflow craicoverflow Nov 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would be a good move. You can remove the localizer and conn fields so and just use this :)

I'd recommend refactoring these completions APIs also to look like this one:

func RegisterNameFlagCompletionFunc(cmd *cobra.Command, f *factory.Factory) error {

They also probably should not be in a generic cmdutil package since they are kafka specific (I did that 😂)

@craicoverflow
Copy link
Contributor

This is ready for review @rkpattnaik780?

@rkpattnaik780
Copy link
Contributor Author

This is ready for review @rkpattnaik780?

Yes.

@craicoverflow
Copy link
Contributor

This is ready for review @rkpattnaik780?

Yes.

Thanks.

@wtrocki
Copy link
Collaborator

wtrocki commented Nov 11, 2021

Documentation needs little bit refinement:
I would use some common prefix to say what flag does - mainly filtering.

Set filter to all-accounts
Set filter to only cluster type

etc.

Current docs are less refined

Flags:
      --all-accounts             Set the ACL principal to match all principals (users and service accounts)
      --cluster                  Set the resource type to cluster
      --group string             Set the consumer group resource. When the --prefix option is also passed, this is used..
      --service-account string   Service account client ID used as principal for this operation

@wtrocki
Copy link
Collaborator

wtrocki commented Nov 11, 2021

Documentation needs improvement. Otherwise ok.

@rkpattnaik780
Copy link
Contributor Author

Documentation needs little bit refinement: I would use some common prefix to say what flag does - mainly filtering.

Set filter to all-accounts Set filter to only cluster type

etc.

Current docs are less refined

Flags:
      --all-accounts             Set the ACL principal to match all principals (users and service accounts)
      --cluster                  Set the resource type to cluster
      --group string             Set the consumer group resource. When the --prefix option is also passed, this is used..
      --service-account string   Service account client ID used as principal for this operation

Falling back to not using flag abstraction here as the descriptions differ a bit owing to --prefix flag.

@rkpattnaik780
Copy link
Contributor Author

Having second thoughts adding a prefix regarding filter operation, wdyt @craicoverflow ?

Copy link
Contributor

@craicoverflow craicoverflow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good and works. However I noticed that the cluster flag still exists and I think we agreed it is not a requirement.

flagName,
"",
fs.localizer.MustLocalize("kafka.acl.common.flag.transactionalID.description"),
fs.factory.Localizer.MustLocalize("kafka.acl.common.flag.transactionalID.description"),
Copy link
Contributor

Choose a reason for hiding this comment

The 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


// FilterValidTopicNameArgs filters topics from the API and returns the names
// This is used in for dynamic completion of topic names
func FilterValidTopicNameArgs(f *factory.Factory, toComplete string) (validNames []string, directive cobra.ShellCompDirective) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these could go in kafka flag util package?

@craicoverflow craicoverflow self-requested a review November 11, 2021 13:58
@rkpattnaik780 rkpattnaik780 merged commit 5ea1f1b into main Nov 12, 2021
@rkpattnaik780 rkpattnaik780 deleted the acl_list_filters branch November 12, 2021 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants