-
Notifications
You must be signed in to change notification settings - Fork 76
/
register.go
64 lines (54 loc) · 1.66 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package v1
import (
"github.com/istio-ecosystem/admiral/admiral/pkg/apis/admiral"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// GroupVersion is the identifier for the API which includes
// the name of the group and the version of the API
var SchemeGroupVersion = schema.GroupVersion{
Group: admiral.GroupName,
Version: "v1alpha1",
}
// create a SchemeBuilder which uses functions to add types to
// the scheme
var (
SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes)
}
// addKnownTypes adds our types to the API scheme by registering
// MyResource and MyResourceList
func addKnownTypes(scheme *runtime.Scheme) error {
//scheme.AddUnversionedTypes(
// SchemeGroupVersion,
// &Dependency{},
// &DependencyList{},
// &GlobalTrafficPolicy{},
// &GlobalTrafficPolicyList{},
//)
scheme.AddKnownTypes(
SchemeGroupVersion,
&Dependency{},
&DependencyList{},
&GlobalTrafficPolicy{},
&GlobalTrafficPolicyList{},
&RoutingPolicy{},
&RoutingPolicyList{},
&DependencyProxy{},
&DependencyProxyList{},
)
// register the type in the scheme
meta_v1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}