-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
install.go
62 lines (51 loc) · 2.19 KB
/
install.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package install
import (
"fmt"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/apis/audit"
auditv1alpha1 "k8s.io/apiserver/pkg/apis/audit/v1alpha1"
configapi "github.com/openshift/origin/pkg/cmd/server/api"
configapiv1 "github.com/openshift/origin/pkg/cmd/server/api/v1"
_ "github.com/openshift/origin/pkg/build/controller/build/defaults/api/install"
_ "github.com/openshift/origin/pkg/build/controller/build/overrides/api/install"
_ "github.com/openshift/origin/pkg/image/admission/imagepolicy/api/install"
_ "github.com/openshift/origin/pkg/ingress/admission/api/install"
_ "github.com/openshift/origin/pkg/project/admission/requestlimit/api/install"
_ "github.com/openshift/origin/pkg/quota/admission/clusterresourceoverride/api/install"
_ "github.com/openshift/origin/pkg/quota/admission/runonceduration/api/install"
_ "github.com/openshift/origin/pkg/scheduler/admission/podnodeconstraints/api/install"
)
var accessor = meta.NewAccessor()
// availableVersions lists all known external versions for this group from most preferred to least preferred
var availableVersions = []schema.GroupVersion{configapiv1.SchemeGroupVersion}
func init() {
configapi.AddToScheme(configapi.Scheme)
configapiv1.AddToScheme(configapi.Scheme)
// we additionally need to enable audit versions, since we embed the audit
// policy file inside master-config.yaml
audit.AddToScheme(configapi.Scheme)
auditv1alpha1.AddToScheme(configapi.Scheme)
}
func interfacesFor(version schema.GroupVersion) (*meta.VersionInterfaces, error) {
switch version {
case configapiv1.SchemeGroupVersion:
return &meta.VersionInterfaces{
ObjectConvertor: configapi.Scheme,
MetadataAccessor: accessor,
}, nil
default:
return nil, fmt.Errorf("unsupported storage version: %s", version)
}
}
func NewRESTMapper() meta.RESTMapper {
mapper := meta.NewDefaultRESTMapper(availableVersions, interfacesFor)
// enumerate all supported versions, get the kinds, and register with the mapper how to address
// our resources.
for _, gv := range availableVersions {
for kind := range configapi.Scheme.KnownTypes(gv) {
mapper.Add(gv.WithKind(kind), meta.RESTScopeRoot)
}
}
return mapper
}