forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.go
48 lines (40 loc) · 1.48 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
package install
import (
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/runtime/schema"
configapi "github.com/openshift/origin/pkg/cmd/server/api"
"github.com/openshift/origin/pkg/project/admission/requestlimit/api"
"github.com/openshift/origin/pkg/project/admission/requestlimit/api/v1"
)
// availableVersions lists all known external versions for this group from most preferred to least preferred
var availableVersions = []schema.GroupVersion{v1.SchemeGroupVersion, v1.LegacySchemeGroupVersion}
func init() {
if err := enableVersions(availableVersions); err != nil {
panic(err)
}
}
// TODO: enableVersions should be centralized rather than spread in each API
// group.
// We can combine registered.RegisterVersions, registered.EnableVersions and
// registered.RegisterGroup once we have moved enableVersions there.
func enableVersions(externalVersions []schema.GroupVersion) error {
addVersionsToScheme(externalVersions...)
return nil
}
func addVersionsToScheme(externalVersions ...schema.GroupVersion) {
// add the internal version to Scheme
api.AddToScheme(configapi.Scheme)
api.AddToSchemeInCoreGroup(configapi.Scheme)
// add the enabled external versions to Scheme
for _, v := range externalVersions {
switch v {
case v1.SchemeGroupVersion:
v1.AddToScheme(configapi.Scheme)
case v1.LegacySchemeGroupVersion:
v1.AddToSchemeInCoreGroup(configapi.Scheme)
default:
glog.Errorf("Version %s is not known, so it will not be added to the Scheme.", v)
continue
}
}
}