Merge pull request #100502 from soltysh/nil_in_printerflags

Prevent nil-pointer exception when constructing PrinterFlags
This commit is contained in:
Kubernetes Prow Robot 2021-03-24 15:17:29 -07:00 committed by GitHub
commit 2a41853329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,6 +65,10 @@ func (f *JSONYamlPrintFlags) ToPrinter(outputFormat string) (printers.ResourcePr
// AddFlags receives a *cobra.Command reference and binds
// flags related to JSON or Yaml printing to it
func (f *JSONYamlPrintFlags) AddFlags(c *cobra.Command) {
if f == nil {
return
}
c.Flags().BoolVar(&f.showManagedFields, "show-managed-fields", f.showManagedFields, "If true, keep the managedFields when printing objects in JSON or YAML format.")
}