-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
register.go
109 lines (85 loc) · 3.74 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017-2021 Authors of Cilium
package v2alpha1
import (
k8sconst "github.com/cilium/cilium/pkg/k8s/apis/cilium.io"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
const (
// CustomResourceDefinitionGroup is the name of the third party resource group
CustomResourceDefinitionGroup = k8sconst.CustomResourceDefinitionGroup
// CustomResourceDefinitionVersion is the current version of the resource
CustomResourceDefinitionVersion = "v2alpha1"
// CustomResourceDefinitionSchemaVersion is semver-conformant version of CRD schema
// Used to determine if CRD needs to be updated in cluster
//
// Maintainers: Run ./Documentation/check-crd-compat-table.sh for each release
// Developers: Bump patch for each change in the CRD schema.
CustomResourceDefinitionSchemaVersion = "1.24.4"
// CustomResourceDefinitionSchemaVersionKey is key to label which holds the CRD schema version
CustomResourceDefinitionSchemaVersionKey = "io.cilium.k8s.crd.schema.version"
// Cilium Egress NAT Policy (CENP)
// CENPSingularName is the singular name of Cilium Egress NAT Policy
CENPSingularName = "ciliumegressnatpolicy"
// CENPPluralName is the plural name of Cilium Egress NAT Policy
CENPPluralName = "ciliumegressnatpolicies"
// CENPKindDefinition is the kind name of Cilium Egress NAT Policy
CENPKindDefinition = "CiliumEgressNATPolicy"
// CENPName is the full name of Cilium Egress NAT Policy
CENPName = CENPPluralName + "." + CustomResourceDefinitionGroup
// Cilium Endpoint Slice (CES)
// CESSingularName is the singular name of Cilium Endpoint Slice
CESSingularName = "ciliumendpointslice"
// CESPluralName is the plural name of Cilium Endpoint Slice
CESPluralName = "ciliumendpointslices"
// CESKindDefinition is the kind name of Cilium Endpoint Slice
CESKindDefinition = "CiliumEndpointSlice"
// CESName is the full name of Cilium Endpoint Slice
CESName = CESPluralName + "." + CustomResourceDefinitionGroup
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{
Group: CustomResourceDefinitionGroup,
Version: CustomResourceDefinitionVersion,
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
// SchemeBuilder is needed by DeepCopy generator.
SchemeBuilder runtime.SchemeBuilder
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
localSchemeBuilder = &SchemeBuilder
// AddToScheme adds all types of this clientset into the given scheme.
// This allows composition of clientsets, like in:
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kuberentes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
AddToScheme = localSchemeBuilder.AddToScheme
)
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)
}
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&CiliumEgressNATPolicy{},
&CiliumEgressNATPolicyList{},
&CiliumEndpointSlice{},
&CiliumEndpointSliceList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}