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 convenience commands #1179

Merged
merged 12 commits into from
Oct 12, 2021
Merged

feat(kafka acl): add convenience commands #1179

merged 12 commits into from
Oct 12, 2021

Conversation

rkpattnaik780
Copy link
Contributor

@rkpattnaik780 rkpattnaik780 commented Oct 5, 2021

Verification Steps

  1. rhoas kafka acl grant-permissions --producer --user user_name --topic "*" should create ACL rules allowing user to write to all topics in the instance.
  2. rhoas kafka acl grant-permissions --consumer --user user_name --topic-prefix "abc" should create ACL rules allowing user to consume from all topics starting with "abc".

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 Oct 5, 2021

Separate PR:
[kafka.acl.list.cmd.longDescription] - let's copy what we have in the documentation to make this more documented.
We can forget about this later

one = 'service account ID to be used as principal'

[kafka.acl.common.flag.topicPrefix.description]
one = 'prefix topic name to define ACL rules for'
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
one = 'prefix topic name to define ACL rules for'
one = 'The prefix topic name to define ACL rules for'

@wtrocki
Copy link
Collaborator

wtrocki commented Oct 6, 2021

All ACL rules are aligned with the Kafka specification/patterns for consuming and producing content.
Great job! Little bit refinement and we can get that in.

For redability I would suggest to define ACL objects close to each other/in the group. Add them into array and then have single method that tries to execute based on that array in the loop. That will allow us to swap easily to batch API when available with single like of code.

@craicoverflow craicoverflow added this to the Kafka ACL commands milestone Oct 6, 2021
Copy link
Collaborator

@wtrocki wtrocki left a comment

Choose a reason for hiding this comment

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

Reverified some mixture of flags and permissions

@craicoverflow
Copy link
Contributor

@rkpattnaik780 could you go through the outstanding/unresolved feedback items and create issues for them to be followed up on?

@craicoverflow
Copy link
Contributor

Getting an i18n error:

$ rhoas kafka acl grant-permissions --service-account srvc1 --consumer --group "*" --topic-prefix "*" --topic "*"
panic: template: :1: unexpected "}" in operand

goroutine 1 [running]:
github.com/nicksnyder/go-i18n/v2/i18n.(*Localizer).MustLocalize(0xc0001ab800, 0xc0000bdbc8, 0x1deeb56, 0x8)
        /home/ephelan/.gvm/pkgsets/go1.16.4/global/pkg/mod/github.com/nicksnyder/go-i18n/[email protected]/i18n/localizer.go:211 +0x7c
github.com/redhat-developer/app-services-cli/pkg/localize/goi18n.(*Goi18n).MustLocalize(0xc00059ad70, 0x1e37997, 0x32, 0xc000010f98, 0x1, 0x1, 0x8, 0x1acb800)
        /home/ephelan/code/github.com/redhat-developer/app-services-cli/pkg/localize/goi18n/go_i18n.go:85 +0x165
github.com/redhat-developer/app-services-cli/pkg/localize/goi18n.(*Goi18n).MustLocalizeError(0xc00059ad70, 0x1e37997, 0x32, 0xc000010f98, 0x1, 0x1, 0xc00021a400, 0xc0000bdcf8)
        /home/ephelan/code/github.com/redhat-developer/app-services-cli/pkg/localize/goi18n/go_i18n.go:95 +0x67
github.com/redhat-developer/app-services-cli/pkg/cmd/kafka/acl/grant.validateFlagInputCombination(0xc00025bad0, 0xc0001dfa20, 0x0)
        /home/ephelan/code/github.com/redhat-developer/app-services-cli/pkg/cmd/kafka/acl/grant/grant.go:298 +0x2c3
github.com/redhat-developer/app-services-cli/pkg/cmd/kafka/acl/grant.NewGrantPermissionsACLCommand.func1(0xc000264000, 0xc000352510, 0x0, 0x9, 0x0, 0x0)
        /home/ephelan/code/github.com/redhat-developer/app-services-cli/pkg/cmd/kafka/acl/grant/grant.go:70 +0x98
github.com/spf13/cobra.(*Command).execute(0xc000264000, 0xc000352480, 0x9, 0x9, 0xc000264000, 0xc000352480)
        /home/ephelan/.gvm/pkgsets/go1.16.4/global/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc00054bb80, 0x20454d4, 0x3, 0xc00054bb80)
        /home/ephelan/.gvm/pkgsets/go1.16.4/global/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /home/ephelan/.gvm/pkgsets/go1.16.4/global/pkg/mod/github.com/spf13/[email protected]/command.go:902
main.main()
        /home/ephelan/code/github.com/redhat-developer/app-services-cli/cmd/rhoas/main.go:43 +0x29d

@craicoverflow
Copy link
Contributor

Getting another i18n error when combining --group and --group-prefix

$ rhoas kafka acl grant-permissions --service-account srvc1 --consumer --group "*" --topic "*" --group-prefix "*"
panic: template: :1: unexpected "}" in operand

goroutine 1 [running]:
github.com/nicksnyder/go-i18n/v2/i18n.(*Localizer).MustLocalize(0xc000209d60, 0xc0004afbc8, 0x1deeb56, 0x8)
        /home/ephelan/.gvm/pkgsets/go1.16.4/global/pkg/mod/github.com/nicksnyder/go-i18n/[email protected]/i18n/localizer.go:211 +0x7c
github.com/redhat-developer/app-services-cli/pkg/localize/goi18n.(*Goi18n).MustLocalize(0xc0000aaf50, 0x1e37997, 0x32, 0xc000465520, 0x1, 0x1, 0x8, 0x1acb800)
        /home/ephelan/code/github.com/redhat-developer/app-services-cli/pkg/localize/goi18n/go_i18n.go:85 +0x165
github.com/redhat-developer/app-services-cli/pkg/localize/goi18n.(*Goi18n).MustLocalizeError(0xc0000aaf50, 0x1e37997, 0x32, 0xc000465520, 0x1, 0x1, 0xc0001a0800, 0xc0004afcf8)
        /home/ephelan/code/github.com/redhat-developer/app-services-cli/pkg/localize/goi18n/go_i18n.go:95 +0x67
github.com/redhat-developer/app-services-cli/pkg/cmd/kafka/acl/grant.validateFlagInputCombination(0xc0004084e0, 0xc000271ad0, 0x0)
        /home/ephelan/code/github.com/redhat-developer/app-services-cli/pkg/cmd/kafka/acl/grant/grant.go:305 +0x1ed
github.com/redhat-developer/app-services-cli/pkg/cmd/kafka/acl/grant.NewGrantPermissionsACLCommand.func1(0xc00040e000, 0xc0004de5a0, 0x0, 0x9, 0x0, 0x0)
        /home/ephelan/code/github.com/redhat-developer/app-services-cli/pkg/cmd/kafka/acl/grant/grant.go:70 +0x98
github.com/spf13/cobra.(*Command).execute(0xc00040e000, 0xc0004de510, 0x9, 0x9, 0xc00040e000, 0xc0004de510)
        /home/ephelan/.gvm/pkgsets/go1.16.4/global/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc000375180, 0x20454d4, 0x3, 0xc000375180)
        /home/ephelan/.gvm/pkgsets/go1.16.4/global/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /home/ephelan/.gvm/pkgsets/go1.16.4/global/pkg/mod/github.com/spf13/[email protected]/command.go:902
main.main()
        /home/ephelan/code/github.com/redhat-developer/app-services-cli/cmd/rhoas/main.go:43 +0x29d

@craicoverflow
Copy link
Contributor

$ rhoas kafka acl grant-permissions --service-account srvc1 --consumer --topic-prefix "*" --group-prefix "*"
❌ Undefined response type. Run the command in verbose mode using the -v flag to see more information

I'm seeing this error again, perhaps @wtrocki's changes were lost from the most recent commit which @rkpattnaik780 did not have locally?

@craicoverflow
Copy link
Contributor

I've fixed it now.

@craicoverflow craicoverflow self-requested a review October 11, 2021 14:42

[kafka.acl.grantPermissions.group.error.notAllowed]
one = 'group flag is allowed only when consumer ACLs are to be added'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure about this message. What that means?

@rkpattnaik780
Copy link
Contributor Author

Not sure about this message. What that means?
@wtrocki this is the error message when --group is passed for producer operation.

@wtrocki
Copy link
Collaborator

wtrocki commented Oct 12, 2021

--group flag is allowed only with --consumer flag

but current message is ok as well

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.

4 participants