-
Notifications
You must be signed in to change notification settings - Fork 173
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: introduce output format flag for zarf tools get-creds
and zarf package list
#3415
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for zarf-docs canceled.
|
Codecov ReportAttention: Patch coverage is
|
if logFile != nil { | ||
logFile.Pause() | ||
defer logFile.Resume() | ||
} |
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.
this was not ported over, but logFile is only used with the legacy logger, and since this now goes to stdout it doesn't go to the logfile anyway
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.
Small nit and notes for future improvements. will reapprove
src/cmd/package.go
Outdated
return err | ||
} | ||
fmt.Fprint(o.outputWriter, string(output)) | ||
case "table": |
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.
Not a blocker, but the table rendering can be done in a reusable way with reflection. One example
func newVersionOptions() *versionOptions { | ||
return &versionOptions{ | ||
outputFormat: "", | ||
// TODO accept output writer as a parameter to the root Zarf command and pass it through here |
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.
👍
cmd.Flags().StringVarP(&o.outputFormat, "output", "o", "", "Output format (yaml|json)") | ||
cmd.Flags().VarP(&o.outputFormat, "output-format", "o", "Output format (yaml|json)") | ||
cmd.Flags().VarP(&o.outputFormat, "output", "", "Output format (yaml|json)") | ||
cmd.Flags().MarkDeprecated("output", "output is deprecated. Please use --output-format instead") |
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.
👍
GetCredsKey string `json:"getCredsKey"` | ||
} | ||
|
||
// TODO Zarf state should be changed to have empty values when a service is not in use |
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.
👍
return err | ||
} | ||
fmt.Fprint(out, string(output)) | ||
case outputTable: |
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.
Non-blocking, but similar comment to above, this can be solved in a reusable way with reflection for table headers.
Signed-off-by: Austin Abro <[email protected]>
f78df60
to
1e77aeb
Compare
Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
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.
LGTM
Description
Introduces the
--output-flag
forzarf tools get-creds
andzarf package list
. Additionally deprecates the--output
flag on zarf version to be--output-format
. There are other commands that print tables in the future such aszarf connect list
andzarf dev lint
.get-creds
andlist
were chosen because the output of these commands is more likely to be used in automation.Related Issue
Relates to #3224
Checklist before merging