mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
add resource prefix to multiple items w/ same kind
This patch ensures that a resource prefix is added to multiple items of the same kind, when using `oc get all`. Before, a prefix was added only when a single item was returned on `oc get all`, but ignored if only a single resource kind existed but multiple items for that kind were returned.
This commit is contained in:
@@ -803,3 +803,36 @@ func HasNames(args []string) (bool, error) {
|
||||
}
|
||||
return hasCombinedTypes || len(args) > 1, nil
|
||||
}
|
||||
|
||||
// MultipleTypesRequested returns true if the provided args contain multiple resource kinds
|
||||
func MultipleTypesRequested(args []string) bool {
|
||||
args = normalizeMultipleResourcesArgs(args)
|
||||
rKinds := sets.NewString()
|
||||
for _, arg := range args {
|
||||
if arg == "all" {
|
||||
return true
|
||||
}
|
||||
rTuple, found, err := splitResourceTypeName(arg)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// if tuple not found, assume arg is of the form "type1,type2,...".
|
||||
// Since SplitResourceArgument returns a unique list of kinds,
|
||||
// return true here if len(uniqueList) > 1
|
||||
if !found {
|
||||
if strings.Contains(arg, ",") {
|
||||
splitArgs := SplitResourceArgument(arg)
|
||||
if len(splitArgs) > 1 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
if rKinds.Has(rTuple.Resource) {
|
||||
continue
|
||||
}
|
||||
rKinds.Insert(rTuple.Resource)
|
||||
}
|
||||
return (rKinds.Len() > 1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user