mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Merge pull request #40046 from juanvallejo/jvallejo/update-multiple-types-requested-check
Automatic merge from submit-queue (batch tested with PRs 40046, 40073, 40547, 40534, 40249) update check for "all" resources This patch updates the check for `all` resources to handle cases where a resource's name is "all". Rather than cycling through all given args until `all` is found, this patch makes sure that only a single argument `all` was specified at all. **Release note**: ```release-note release-note-none ``` @fabianofranz @pwittrock
This commit is contained in:
commit
bef60b8602
@ -806,12 +806,13 @@ func HasNames(args []string) (bool, error) {
|
|||||||
|
|
||||||
// MultipleTypesRequested returns true if the provided args contain multiple resource kinds
|
// MultipleTypesRequested returns true if the provided args contain multiple resource kinds
|
||||||
func MultipleTypesRequested(args []string) bool {
|
func MultipleTypesRequested(args []string) bool {
|
||||||
|
if len(args) == 1 && args[0] == "all" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
args = normalizeMultipleResourcesArgs(args)
|
args = normalizeMultipleResourcesArgs(args)
|
||||||
rKinds := sets.NewString()
|
rKinds := sets.NewString()
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
if arg == "all" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
rTuple, found, err := splitResourceTypeName(arg)
|
rTuple, found, err := splitResourceTypeName(arg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
|
@ -1255,6 +1255,14 @@ func TestMultipleTypesRequested(t *testing.T) {
|
|||||||
args: []string{"rc"},
|
args: []string{"rc"},
|
||||||
expectedMultipleTypes: false,
|
expectedMultipleTypes: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
args: []string{"pod,all"},
|
||||||
|
expectedMultipleTypes: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: []string{"all,rc,pod"},
|
||||||
|
expectedMultipleTypes: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
args: []string{"rc,pod,svc"},
|
args: []string{"rc,pod,svc"},
|
||||||
expectedMultipleTypes: true,
|
expectedMultipleTypes: true,
|
||||||
@ -1287,7 +1295,7 @@ func TestMultipleTypesRequested(t *testing.T) {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
hasMultipleTypes := MultipleTypesRequested(test.args)
|
hasMultipleTypes := MultipleTypesRequested(test.args)
|
||||||
if hasMultipleTypes != test.expectedMultipleTypes {
|
if hasMultipleTypes != test.expectedMultipleTypes {
|
||||||
t.Errorf("expected HasName to return %v for %s", test.expectedMultipleTypes, test.args)
|
t.Errorf("expected MultipleTypesRequested to return %v for %s", test.expectedMultipleTypes, test.args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user