Skip to content
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(kafka acl): add base and list command #1173

Merged
merged 4 commits into from
Oct 4, 2021
Merged

Conversation

rkpattnaik780
Copy link
Contributor

This PR adds rhoas kafka acl list command to list all the Kafka ACL rules for a given instance.

Closes #1172

Verification Steps

  1. rhoas kafka -h should display acl in list of sub commands
  2. rhoas kafka acl list should display ACL rules for the selected Kafka instance.

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

@rkpattnaik780 rkpattnaik780 removed the request for review from craicoverflow October 4, 2021 12:39

[kafka.acl.cmd.example]
one = '''

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this newline


[kafka.acl.cmd.longDescription]
one = '''
Set of commands that will let you manage resources
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Set of commands that will let you manage resources
Set of commands that will let you manage resources.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe "Kafka instance resources"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

typo, will make it Manage Kafka ACLs.

@rkpattnaik780 rkpattnaik780 changed the base branch from main to kafka_acl October 4, 2021 13:41
@craicoverflow
Copy link
Contributor

image

I'm seeing an unexpected order of items. The UI shows a different order. The order from the CLI is the exact order that is returned from the API.

@wtrocki
Copy link
Collaborator

wtrocki commented Oct 4, 2021

UI have numerous bugs logged in and still has some major development. I would not use it as a source of truth for the moment.


cmd.Flags().Int32VarP(&opts.page, "page", "", cmdutil.ConvertPageValueToInt32(build.DefaultPageNumber), opts.localizer.MustLocalize("kafka.acl.list.flag.page.description"))
cmd.Flags().Int32VarP(&opts.size, "size", "", cmdutil.ConvertSizeValueToInt32(build.DefaultPageSize), opts.localizer.MustLocalize("kafka.acl.list.flag.size.description"))
cmd.Flags().StringVarP(&opts.output, "output", "o", "", opts.localizer.MustLocalize("kafka.acl.list.flag.output.description"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cmd.Flags().StringVarP(&opts.output, "output", "o", "", opts.localizer.MustLocalize("kafka.acl.list.flag.output.description"))
cmd.Flags().StringVarP(&opts.output, "output", "o", dump.EmptyFormat, opts.localizer.MustLocalize("kafka.acl.list.flag.output.description"))

Comment on lines 96 to 102
req := api.AclsApi.GetAcls(opts.Context)

req.Page(float32(opts.page))

req.Size(float32(opts.size))

permissionsData, httpRes, err := req.Execute()
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a matter of preference but this could be chained as it is a builder. Which do you prefer?

func formatPrincipal(principal string, localizer localize.Localizer) string {
s := strings.Split(principal, ":")[1]

if s == "*" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if s == "*" {
if s == acl.Wildcard {

Something like this will be useful.

@craicoverflow
Copy link
Contributor

UI have numerous bugs logged in and still has some major development. I would not use it as a source of truth for the moment.

Either way, I was expecting the last created ACL to appear at the bottom. How is it determined?

Comment on lines +46 to +47
## Display Kafka ACL rules for the instance
rhoas kafka acl list
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
## Display Kafka ACL rules for the instance
rhoas kafka acl list
# Display Kafka ACL rules for the instance
$ rhoas kafka acl list



[kafka.acl.list.flag.output.description]
description = "Description for --output flag"
Copy link
Contributor

Choose a reason for hiding this comment

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

descriptions of flag i18n messages are redundant. Could be removed

Comment on lines +150 to +151
Permission: fmt.Sprintf("%s | %s", p.GetPermission(), p.GetOperation()),
Description: fmt.Sprintf("%s %s \"%s\"", p.GetResourceType(), description, p.GetResourceName()),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should map raw ACL values to something more human readable. Example GROUP => Consumer Group, CLUSTER => Kafka instance.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would keep them as in spec and aligned with the way our documentation will cover them

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah makes sense.

Comment on lines 98 to 100
req.Page(float32(opts.page))

req.Size(float32(opts.size))
Copy link
Contributor

Choose a reason for hiding this comment

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

These values are not being included because you need to use a builder or else reassign to reg like req = req.*

Copy link
Collaborator

@wtrocki wtrocki Oct 4, 2021

Choose a reason for hiding this comment

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

Let's address this if possible in this PR!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Will merge it for now and raise a follow up.

@craicoverflow craicoverflow self-requested a review October 4, 2021 14:23
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 good except pagination is not working.

@craicoverflow craicoverflow self-requested a review October 4, 2021 14:24
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.

@rkpattnaik780 can you merge this and follow up on the comments in another PR (maybe create issues to track them). I need this closed as it included the base command.

@wtrocki
Copy link
Collaborator

wtrocki commented Oct 4, 2021

Nice to have and great way to wrap your head around API.
Great work @rkpattnaik780

@rkpattnaik780 @craicoverflow let's release SDK as well - we basing on non recent changes which might cause some issues in some API's (incompatible changes were made)

@rkpattnaik780 rkpattnaik780 merged commit 19db1da into kafka_acl Oct 4, 2021
@rkpattnaik780 rkpattnaik780 deleted the kafka_acl_cmd branch October 4, 2021 14:54
craicoverflow pushed a commit to craicoverflow/app-services-cli that referenced this pull request Oct 7, 2021
craicoverflow pushed a commit to craicoverflow/app-services-cli that referenced this pull request Oct 7, 2021
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.

Add kafka acl list command to list ACL rules
3 participants