...
1
16
17 package v1beta1
18
19 import (
20 "bytes"
21
22 "k8s.io/apimachinery/pkg/conversion"
23 "k8s.io/apimachinery/pkg/util/json"
24
25 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
26 )
27
28 func Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(in *apiextensions.JSONSchemaProps, out *JSONSchemaProps, s conversion.Scope) error {
29 if err := autoConvert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(in, out, s); err != nil {
30 return err
31 }
32 if in.Default != nil && *(in.Default) == nil {
33 out.Default = nil
34 }
35 if in.Example != nil && *(in.Example) == nil {
36 out.Example = nil
37 }
38 return nil
39 }
40
41 var nullLiteral = []byte(`null`)
42
43 func Convert_apiextensions_JSON_To_v1beta1_JSON(in *apiextensions.JSON, out *JSON, s conversion.Scope) error {
44 raw, err := json.Marshal(*in)
45 if err != nil {
46 return err
47 }
48 if len(raw) == 0 || bytes.Equal(raw, nullLiteral) {
49
50 out.Raw = nil
51 } else {
52 out.Raw = raw
53 }
54 return nil
55 }
56
57 func Convert_v1beta1_JSON_To_apiextensions_JSON(in *JSON, out *apiextensions.JSON, s conversion.Scope) error {
58 if in != nil {
59 var i interface{}
60 if len(in.Raw) > 0 && !bytes.Equal(in.Raw, nullLiteral) {
61 if err := json.Unmarshal(in.Raw, &i); err != nil {
62 return err
63 }
64 }
65 *out = i
66 } else {
67 out = nil
68 }
69 return nil
70 }
71
View as plain text