-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-5306. Add ozone sh * getacl option to match setacl input format
#9564
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
base: master
Are you sure you want to change the base?
Conversation
…it is fed to setacl
ozone sh * getacl option to match setacl input format
| */ | ||
| public abstract class GetAclHandler extends AclHandler { | ||
|
|
||
| @Option(names = {"--string", "-o"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @echonesis for working on this task.
I would suggest add an following Option instead of this one,
@CommandLine.Option(names = {"--json"},
description = "Format output as JSON",
defaultValue = "true")
private boolean json;
The rest looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review!
I've been considering the --json approach with the following concerns:
- Clearer user intent: The --string flag explicitly opts into the string format, while --json with defaultValue="true" creates confusion (why have a flag for the default behavior?).
- Backward compatibility: The current implementation maintains the existing default JSON output without any flags, which is less disruptive to existing users.
- Future extensibility: If we need additional formats (e.g.,
--xmlor--yaml), having explicit format flags is cleaner than having--json=falsealongside other format flags.
What do you think? I'm open to your perspective on this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very good to thought that there are possible other formats to support in future. But the current Ozone CLI state is either json or plain output without structured format, so --json is used in many CLIs. To have a consistent CLI option format, --json is preferred. There is possibility to support xml or yaml in future, but we don't see such requirements so far. If it becomes true, then a lot of existing CLIs need to improved in batches.
why have a flag for the default behavior?
If there is --json in the command line, then it's true, otherwise it's false. So default "true" might not be feasible, "false" is more appropriate.
"--string", "-o"
"--string" is kind of vague, user cannot get the clear idea about what this option means without looking into description, and "-o" usually means "--output-file". A self explained option name is more preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess(didn't test it) defaultValue = "true" will cause problem, there could be no way to get a false state, could you test it if defaultValue = "true" works? The reason why defaultValue = "true" is recommended at first place is to keep the backward compatibility, but if it's not feasible, I think defaultValue = "false" is acceptable, though it will change the current output behavior, but just format, not content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the Option settings, and it works for backward compatibility.
- default: JSON
- with
--json: JSON - with
--json=false: String
We could use the syntax:
@Option(names = {"--json"},
description = "Format output as JSON",
defaultValue = "true",
fallbackValue = "true")
private boolean json;
| public abstract class GetAclHandler extends AclHandler { | ||
|
|
||
| @Option(names = {"--json"}, | ||
| description = "Format output as JSON", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add more explanation in description.
Format output as JSON. Default is true. Use --json=false to turn off output JSON format.
What changes were proposed in this pull request?
Enhanced the
ozone sh bucket|key|volume getaclcommand to support a--jsonflag.The command now outputs JSON format by default (consistent with other Ozone CLI commands).
Users can use
--json=falseto get a comma-separated string format compatible with setacl/addacl commands.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-5306
How was this patch tested?
GitHub Actions CI: https://github.com/echonesis/ozone/actions/runs/20594091686
Local Test: