update vendor

Signed-off-by: Roland.Ma <rolandma@yunify.com>
This commit is contained in:
Roland.Ma
2021-08-11 07:10:14 +00:00
parent a18f72b565
commit ea8f47c73a
2901 changed files with 269317 additions and 43103 deletions

View File

@@ -24,6 +24,7 @@ import (
"k8s.io/cli-runtime/pkg/printers"
)
// AllowedFormats returns slice of string of allowed JSONYaml printing format
func (f *JSONYamlPrintFlags) AllowedFormats() []string {
if f == nil {
return []string{}
@@ -35,6 +36,7 @@ func (f *JSONYamlPrintFlags) AllowedFormats() []string {
// Given the following flag values, a printer can be requested that knows
// how to handle printing based on these values.
type JSONYamlPrintFlags struct {
showManagedFields bool
}
// ToPrinter receives an outputFormat and returns a printer capable of
@@ -54,12 +56,21 @@ func (f *JSONYamlPrintFlags) ToPrinter(outputFormat string) (printers.ResourcePr
return nil, NoCompatiblePrinterError{OutputFormat: &outputFormat, AllowedFormats: f.AllowedFormats()}
}
if !f.showManagedFields {
printer = &printers.OmitManagedFieldsPrinter{Delegate: printer}
}
return printer, nil
}
// AddFlags receives a *cobra.Command reference and binds
// flags related to JSON or Yaml printing to it
func (f *JSONYamlPrintFlags) AddFlags(c *cobra.Command) {}
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.")
}
// NewJSONYamlPrintFlags returns flags associated with
// yaml or json printing, with default values set.