mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
fix print format of rootScoped resourced
This commit is contained in:
parent
4ff6ef4a37
commit
2437b59266
@ -244,7 +244,14 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
|
|||||||
}
|
}
|
||||||
info := infos[0]
|
info := infos[0]
|
||||||
mapping := info.ResourceMapping()
|
mapping := info.ResourceMapping()
|
||||||
printer, err := f.PrinterForMapping(cmd, false, nil, mapping, allNamespaces)
|
|
||||||
|
// no need to print namespace for root-scoped resources
|
||||||
|
printWithNamespace := allNamespaces
|
||||||
|
if mapping != nil && mapping.Scope.Name() == meta.RESTScopeNameRoot {
|
||||||
|
printWithNamespace = false
|
||||||
|
}
|
||||||
|
|
||||||
|
printer, err := f.PrinterForMapping(cmd, false, nil, mapping, printWithNamespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -493,6 +500,11 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
|
|||||||
w.Flush()
|
w.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printWithNamespace := allNamespaces
|
||||||
|
if mapping != nil && mapping.Scope.Name() == meta.RESTScopeNameRoot {
|
||||||
|
printWithNamespace = false
|
||||||
|
}
|
||||||
|
|
||||||
var outputOpts *printers.OutputOptions
|
var outputOpts *printers.OutputOptions
|
||||||
// if cmd does not specify output format and useOpenAPIPrintColumnFlagLabel flag is true,
|
// if cmd does not specify output format and useOpenAPIPrintColumnFlagLabel flag is true,
|
||||||
// then get the default output options for this mapping from OpenAPI schema.
|
// then get the default output options for this mapping from OpenAPI schema.
|
||||||
@ -500,7 +512,7 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
|
|||||||
outputOpts, _ = outputOptsForMappingFromOpenAPI(f, mapping)
|
outputOpts, _ = outputOptsForMappingFromOpenAPI(f, mapping)
|
||||||
}
|
}
|
||||||
|
|
||||||
printer, err = f.PrinterForMapping(cmd, false, outputOpts, mapping, allNamespaces)
|
printer, err = f.PrinterForMapping(cmd, false, outputOpts, mapping, printWithNamespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errs.Has(err.Error()) {
|
if !errs.Has(err.Error()) {
|
||||||
errs.Insert(err.Error())
|
errs.Insert(err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user