forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multimapper.go
34 lines (30 loc) · 1 KB
/
multimapper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package meta
import (
kmeta "github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
)
// MultiRESTMapper is a wrapper for multiple RESTMappers.
type MultiRESTMapper []kmeta.RESTMapper
// VersionAndKindForResource provides the Version and Kind mappings for the
// REST resources. This implementation supports multiple REST schemas and return
// the first match.
func (m MultiRESTMapper) VersionAndKindForResource(resource string) (defaultVersion, kind string, err error) {
for _, t := range m {
defaultVersion, kind, err = t.VersionAndKindForResource(resource)
if err == nil {
return
}
}
return
}
// RESTMapping provides the REST mapping for the resource based on the resource
// kind and version. This implementation supports multiple REST schemas and
// return the first match.
func (m MultiRESTMapper) RESTMapping(kind string, versions ...string) (mapping *kmeta.RESTMapping, err error) {
for _, t := range m {
mapping, err = t.RESTMapping(kind, versions...)
if err == nil {
return
}
}
return
}