Conversation
|
Deleting all acls for a principal. |
|
Not sure if we should allow all accounts as well? |
|
Seeing some strange issue/inconsitencies: |
|
Ok. So problem is with Pattern Type. because we assume Literal pattern type is provided by default there is no easy way for us to fix that without breaking CLI. I will need to add explicit pattern-type=none and deprecated --prefix to get around this |
|
@craicoverflow @rkpattnaik780 I have managed to workaround problem by introducing new flag called pattern type and deprecated prefix. Not sure if we should be deprecating prefix or still keep it? |
|
Pattern type is fine to use. I used "prefix" because this is what confluent CLI does. |
|
I still removed depreciation from prefix as it is much simpler/neater flag. We have pattern-type=all only because there is no other way to reflect it now. When none is specified it should be literal and prefix stays as it is. Obviously pattern type supports all other flags but that is too verbose IMHO for regular use |
UI allows deleting permissions for all accounts. We should keep it too. |
| } | ||
|
|
||
| opts.PatternType = aclcmdutil.PatternTypeLITERAL | ||
| // Backwards compatibility: |
There was a problem hiding this comment.
This should be moved after the switch in 264.
Current behavior keeps pattern type as literal if we pass --prefix flag.
./rhoas kafka acl delete --user enda --topic "rhoas-" --prefix -v
/rest/acls?patternType=LITERAL&permission=ANY&principal=User%3Aenda&resourceName=rhoas-&resourceType=TOPIC
There was a problem hiding this comment.
Oh.. I did refactor if into switch and introduced that bug. Really hate that golanglint forces us to use switch statements even when they do not make sense
There was a problem hiding this comment.
You could always look to remove that rule from the lint config file? It is not a rule coming from the Go stdlib or anything.
| one = 'Determine if the resource should be exact match or prefix' | ||
|
|
||
| [kafka.acl.common.flag.patterntypes.description] | ||
| one = 'Determine if the resource should be exact match, prefix or any {{.Types}}' |
There was a problem hiding this comment.
The flag description looks odd
Determine if the resource should be exact match, prefix or any [any literal prefix] (default "literal")
Should we keep options in description only?
There was a problem hiding this comment.
It is good to give list of values in canonical form. Will remove them from description
There was a problem hiding this comment.
Yes you are right @wtrocki it is good to, but currently they are not. The output that @rkpattnaik780 shows is the exact output from the command.
That was different POC. Removing it |
craicoverflow
left a comment
There was a problem hiding this comment.
Verified. I left one suggestion regarding printing deprecation message from within the command output aswell as in the description.
| cmd.Flags().StringVar( | ||
| &patternTypeFlag, | ||
| "pattern-type", | ||
| aclcmdutil.PatternTypeLITERAL, | ||
| opts.Localizer.MustLocalize("kafka.acl.common.flag.patterntypes.description", | ||
| localize.NewEntry("Types", aclcmdutil.PatternTypes)), | ||
| ) | ||
|
|
||
| _ = cmd.RegisterFlagCompletionFunc("pattern-type", func(cmd *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
| return aclcmdutil.PatternTypes, cobra.ShellCompDirectiveNoSpace | ||
| }) |
There was a problem hiding this comment.
It'd be nice to add this into the flag package we have created? I know it is not used in other commands but it does abstract it away and make the command setup much easier to read.
There was a problem hiding this comment.
I think flag package is overkill
There was a problem hiding this comment.
The package already exists though, so don't see how (there is no extra code involved).
| } | ||
|
|
||
| opts.PatternType = aclcmdutil.PatternTypeLITERAL | ||
| // Backwards compatibility: |
There was a problem hiding this comment.
You could always look to remove that rule from the lint config file? It is not a rule coming from the Go stdlib or anything.
| // DeprecateFlag provides a way to deprecate a flag by appending standard prefixes to the flag description. | ||
| func DeprecateFlag(flagDescription string) string { | ||
| return "DEPRECATED: " + flagDescription | ||
| } |
There was a problem hiding this comment.
I also think that when a deprecated flag is used, the command should print a message like:
$ rhoas kafka acl delete --prefix
The "--prefix" flag has been deprecated, in the future please use "--pattern-type"
... delete outputThe reason being that existing users of the CLI will not be checking the flag descriptions any more as they already understand the purpose of the prefix flag, so will likely never see that it is deprecated.
There was a problem hiding this comment.
Fully agree. I will remove that method as it is not used right now and it is not properly implemented.
| one = 'Determine if the resource should be exact match or prefix' | ||
|
|
||
| [kafka.acl.common.flag.patterntypes.description] | ||
| one = 'Determine if the resource should be exact match, prefix or any {{.Types}}' |
There was a problem hiding this comment.
Yes you are right @wtrocki it is good to, but currently they are not. The output that @rkpattnaik780 shows is the exact output from the command.
| $ rhoas kafka acl delete --operation all --permission any --topic "rhoas" --prefix --service-account "srvc-acct-11924479-43fe-42b4-9676-cf0c9aca81" | ||
|
|
||
| # Delete all ACLs for a service account | ||
| $ rhoas kafka acl delete --service-account "srvc-acct-11924479-43fe-42b4-9676-cf0c9aca81 --pattern-type=all" |
There was a problem hiding this comment.
Is pattern type needed in order to do this?
There was a problem hiding this comment.
Yes. While it is counter intuitive we need backwards compatibility.
So:
- nothing provided - exact match
- all - take all
- prefix (use prefix)
etc.
Rule itself is good, but it does have lots of false positives - where doing switch is not possible. |

Creating for early feedback for #1430
Validation for delete command were redundant preventing users from deleting multiple acls.
For example it would not be possible to remove all ACLs for Service account.
After this change it is possible:
However we need to still spend some time cleaning up messages/validation and arguments to API.
Posted for early feedback
Verification
Delete all write operations for sa
other variations