forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
register.go
46 lines (38 loc) · 1.34 KB
/
register.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
package v1
import (
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/openshift/origin/pkg/image/apiserver/admission/apis/imagepolicy"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: "", Version: "v1"}
var (
SchemeBuilder = runtime.NewSchemeBuilder(
addKnownTypes,
imagepolicy.InstallLegacy,
addConversionFuncs,
addDefaultingFuncs,
)
InstallLegacy = SchemeBuilder.AddToScheme
)
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ImagePolicyConfig{},
)
return nil
}
func addConversionFuncs(scheme *runtime.Scheme) error {
return scheme.AddConversionFuncs(
// TODO: remove when MatchSignatures is implemented
func(in *ImageCondition, out *imagepolicy.ImageCondition, s conversion.Scope) error {
return s.DefaultConvert(in, out, conversion.IgnoreMissingFields)
},
// TODO: remove when ConsumptionRules and PlacementRules are implemented
func(in *ImagePolicyConfig, out *imagepolicy.ImagePolicyConfig, s conversion.Scope) error {
return s.DefaultConvert(in, out, conversion.IgnoreMissingFields)
},
)
}
func (obj *ImagePolicyConfig) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }