Merge pull request #49132 from deads2k/cli-01-union-category

Automatic merge from submit-queue (batch tested with PRs 49055, 49128, 49132, 49134, 49110)

add a union category expander

Adds a union category expander for use when we need to combined hardcoded and non-hardcoded options.
pull/6/head
Kubernetes Submit Queue 2017-07-18 21:54:22 -07:00 committed by GitHub
commit 8337bd028d
1 changed files with 27 additions and 0 deletions

View File

@ -79,6 +79,33 @@ func (e discoveryFilteredExpander) Expand(category string) ([]schema.GroupResour
return available, ok
}
type UnionCategoryExpander []CategoryExpander
func (u UnionCategoryExpander) Expand(category string) ([]schema.GroupResource, bool) {
ret := []schema.GroupResource{}
ok := false
for _, expansion := range u {
curr, currOk := expansion.Expand(category)
for _, currGR := range curr {
found := false
for _, existing := range ret {
if existing == currGR {
found = true
break
}
}
if !found {
ret = append(ret, currGR)
}
}
ok = ok || currOk
}
return ret, ok
}
// legacyUserResources are the resource names that apply to the primary, user facing resources used by
// client tools. They are in deletion-first order - dependent resources should be last.
// Should remain exported in order to expose a current list of resources to downstream