-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
fix kubectl -o #64371
fix kubectl -o #64371
Conversation
/test pull-kubernetes-e2e-kops-aws |
/assign @adohe |
/test pull-kubernetes-e2e-kops-aws |
/test pull-kubernetes-e2e-gce-device-plugin-gpu |
/assign @soltysh |
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.
If you manage to update that by the end of today ping me on slack and I'll push that forward.
@@ -40,6 +40,10 @@ func (f *NamePrintFlags) Complete(successTemplate string) error { | |||
return nil | |||
} | |||
|
|||
func (f *NamePrintFlags) AllowedFormats() []string { | |||
return []string{"name", `""`} |
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'd rather we don't say empty is allowed format.
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.
Done.
pkg/printers/template_flags.go
Outdated
@@ -36,6 +36,10 @@ type GoTemplatePrintFlags struct { | |||
TemplateArgument *string | |||
} | |||
|
|||
func (f *GoTemplatePrintFlags) AllowedFormats() []string { | |||
return []string{"template", "go-template", "go-template-file", "templatefile"} |
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.
We already have a map of supported formats, see ToPrinter
method. We should have a single source of truth with these.
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.
Done.
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.
Also modified in:
jsonpath_flags.go
customcolumn_flags.go
Fix kubectl -o error message: Before this change: ```shell kubectl get pods -o foo error: unable to match a printer suitable for the output format "" and the options specified: &get.PrintFlags{JSONYamlPrintFlags:(*genericclioptions.JSONYamlPrintFlags)(0x23aa610), NamePrintFlags:(*genericclioptions.NamePrintFlags)(0xc42058b4e0), TemplateFlags:(*printers.KubeTemplatePrintFlags)(0xc4206765e0), CustomColumnsFlags:(*printers.CustomColumnsPrintFlags)(0xc420676620), HumanReadableFlags:(*get.HumanPrintFlags)(0xc4204eb180), NoHeaders:(*bool)(0xc4206fefbc), OutputFormat:(*string)(0xc42058b4d0)} ``` After this change: ```shell Kubectl get pods -o foo error: unable to match a printer suitable for the output format "aaa", allowed formats are: custom-columns,custom-columns-file,go-template,go-template-file,json,jsonpath,jsonpath-file,name,template,templatefile,wide,yaml ```
@@ -35,7 +38,8 @@ func (e NoCompatiblePrinterError) Error() string { | |||
output = *e.OutputFormat | |||
} | |||
|
|||
return fmt.Sprintf("unable to match a printer suitable for the output format %q and the options specified: %#v", output, e.Options) | |||
sort.Strings(e.AllowedFormats) |
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.
@soltysh
Since I use range map[key]bool
to iterate the map.
The order of output would be uncertain. So I add a sort 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.
I don't think I care about this, but ok.
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
/approve
@@ -35,7 +38,8 @@ func (e NoCompatiblePrinterError) Error() string { | |||
output = *e.OutputFormat | |||
} | |||
|
|||
return fmt.Sprintf("unable to match a printer suitable for the output format %q and the options specified: %#v", output, e.Options) | |||
sort.Strings(e.AllowedFormats) |
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 don't think I care about this, but ok.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CaoShuFeng, soltysh 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 |
This was tagged before the code freeze, I'm changing the labels to get this in, still. |
[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process Pull Request Labels
|
/test pull-kubernetes-node-e2e |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Fix kubectl -o error message:
Before this change:
After this change:
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Release note: