-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
register.go
46 lines (39 loc) · 1.16 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 v1beta3
import (
"fmt"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/runtime"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"}
// Codec encodes internal objects to the v1beta3 scheme
var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String())
func init() {
api.Scheme.AddKnownTypes(SchemeGroupVersion,
&Route{},
&RouteList{},
)
}
func addConversionFuncs() {
// Add field conversion funcs.
err := api.Scheme.AddFieldLabelConversionFunc("v1beta3", "Route",
func(label, value string) (string, string, error) {
switch label {
case "metadata.name",
"spec.host",
"spec.path",
"spec.to.name":
return label, value, nil
// This is for backwards compatibility with old v1 clients which send spec.host
default:
return "", "", fmt.Errorf("field label not supported: %s", label)
}
})
if err != nil {
// If one of the conversion functions is malformed, detect it immediately.
panic(err)
}
}
func (*Route) IsAnAPIObject() {}
func (*RouteList) IsAnAPIObject() {}