Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / k8s.io / apimachinery / pkg / apis / meta / v1 / register.go
1 /*
2 Copyright 2014 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8     http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package v1
18
19 import (
20         "k8s.io/apimachinery/pkg/runtime"
21         "k8s.io/apimachinery/pkg/runtime/schema"
22         utilruntime "k8s.io/apimachinery/pkg/util/runtime"
23 )
24
25 // GroupName is the group name for this API.
26 const GroupName = "meta.k8s.io"
27
28 // SchemeGroupVersion is group version used to register these objects
29 var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
30
31 // Unversioned is group version for unversioned API objects
32 // TODO: this should be v1 probably
33 var Unversioned = schema.GroupVersion{Group: "", Version: "v1"}
34
35 // WatchEventKind is name reserved for serializing watch events.
36 const WatchEventKind = "WatchEvent"
37
38 // Kind takes an unqualified kind and returns a Group qualified GroupKind
39 func Kind(kind string) schema.GroupKind {
40         return SchemeGroupVersion.WithKind(kind).GroupKind()
41 }
42
43 // AddToGroupVersion registers common meta types into schemas.
44 func AddToGroupVersion(scheme *runtime.Scheme, groupVersion schema.GroupVersion) {
45         scheme.AddKnownTypeWithName(groupVersion.WithKind(WatchEventKind), &WatchEvent{})
46         scheme.AddKnownTypeWithName(
47                 schema.GroupVersion{Group: groupVersion.Group, Version: runtime.APIVersionInternal}.WithKind(WatchEventKind),
48                 &InternalEvent{},
49         )
50         // Supports legacy code paths, most callers should use metav1.ParameterCodec for now
51         scheme.AddKnownTypes(groupVersion,
52                 &ListOptions{},
53                 &ExportOptions{},
54                 &GetOptions{},
55                 &DeleteOptions{},
56                 &CreateOptions{},
57                 &UpdateOptions{},
58         )
59         utilruntime.Must(scheme.AddConversionFuncs(
60                 Convert_v1_WatchEvent_To_watch_Event,
61                 Convert_v1_InternalEvent_To_v1_WatchEvent,
62                 Convert_watch_Event_To_v1_WatchEvent,
63                 Convert_v1_WatchEvent_To_v1_InternalEvent,
64         ))
65         // Register Unversioned types under their own special group
66         scheme.AddUnversionedTypes(Unversioned,
67                 &Status{},
68                 &APIVersions{},
69                 &APIGroupList{},
70                 &APIGroup{},
71                 &APIResourceList{},
72         )
73
74         // register manually. This usually goes through the SchemeBuilder, which we cannot use here.
75         utilruntime.Must(AddConversionFuncs(scheme))
76         utilruntime.Must(RegisterDefaults(scheme))
77 }
78
79 // scheme is the registry for the common types that adhere to the meta v1 API spec.
80 var scheme = runtime.NewScheme()
81
82 // ParameterCodec knows about query parameters used with the meta v1 API spec.
83 var ParameterCodec = runtime.NewParameterCodec(scheme)
84
85 func init() {
86         scheme.AddUnversionedTypes(SchemeGroupVersion,
87                 &ListOptions{},
88                 &ExportOptions{},
89                 &GetOptions{},
90                 &DeleteOptions{},
91                 &CreateOptions{},
92                 &UpdateOptions{},
93         )
94
95         // register manually. This usually goes through the SchemeBuilder, which we cannot use here.
96         utilruntime.Must(RegisterDefaults(scheme))
97 }