mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Make REST mappings for resources a unique list
This ensures the mappings list for resources(shortcuts, plural) unique, instead of doing multiple requests to server for the same resource.
This commit is contained in:
parent
8f4f07fcc1
commit
6be1b975d2
@ -622,11 +622,17 @@ func (b *Builder) resourceMappings() ([]*meta.RESTMapping, error) {
|
||||
return nil, fmt.Errorf("you may only specify a single resource type")
|
||||
}
|
||||
mappings := []*meta.RESTMapping{}
|
||||
seen := map[schema.GroupVersionKind]bool{}
|
||||
for _, r := range b.resources {
|
||||
mapping, err := b.mappingFor(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// This ensures the mappings for resources(shortcuts, plural) unique
|
||||
if seen[mapping.GroupVersionKind] {
|
||||
continue
|
||||
}
|
||||
seen[mapping.GroupVersionKind] = true
|
||||
|
||||
mappings = append(mappings, mapping)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user