-
Notifications
You must be signed in to change notification settings - Fork 39.6k
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
Cherry pick 65711 65786 65982 #65979
Cherry pick 65711 65786 65982 #65979
Conversation
Fixes defaulting done for commands that default to a specific output format (such as yaml, json) when a --template flag is provided and no explicit --output value is given. Under the above case, these commands will now properly default to honoring the --template argument given, and default their --output format to "go-template".
// For backwards compatibility we want to support a --template argument given, even when no --output format is provided. | ||
// If a default output format has been set, but no explicit output format has been provided via the --output flag, fallback | ||
// to honoring the --template argument. | ||
if f.TemplatePrinterFlags != nil && f.TemplatePrinterFlags.TemplateArgument != nil && |
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.
use bool assignments to make this readable for me to stumble through.
// to honoring the --template argument. | ||
if f.TemplatePrinterFlags != nil && f.TemplatePrinterFlags.TemplateArgument != nil && | ||
len(*f.TemplatePrinterFlags.TemplateArgument) > 0 && | ||
(len(outputFormat) == 0 || (f.outputDefaulted && !f.outputFlag.Changed)) { |
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.
doesn't this change make it impossible to compose this without specifically adding these flags?
} | ||
} | ||
|
||
// WithDefaultOutput sets a default output format if one is not provided through a flag value | ||
func (f *PrintFlags) WithDefaultOutput(output string) *PrintFlags { | ||
f.OutputFormat = &output | ||
f.outputDefaulted = true |
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 seems wrong. Why do we have this instead of knowing it from the AddFlags call at the point at which it was bound?
Can we close #65873 then? |
/lgtm |
done |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, juanvallejo The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/status approved-for-milestone |
/kind bug |
/priority important-soon |
[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process Pull Request Labels
|
@foxish for cherry-pick approval |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. |
What this PR does / why we need it:
This cherry picks #65711, #65786, and #65982 onto release 1.11.
Special notes for your reviewer:
Picks and rebases existing cherry-pick #65873
Fixes #65647
Release note:
/assign @deads2k
for review
/assign @foxish
for 1.11 approval