Prevent nil-pointer exception when constructing PrinterFlags

This commit is contained in:
Maciej Szulik 2021-03-23 20:42:35 +01:00
parent cf3374e434
commit 81d9606554
No known key found for this signature in database
GPG Key ID: F15E55D276FA84C4

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.")
}