-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
conversion.go
57 lines (48 loc) · 1.56 KB
/
conversion.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
package v1
import (
"k8s.io/kubernetes/pkg/runtime"
oapi "github.com/openshift/origin/pkg/api"
"github.com/openshift/origin/pkg/api/extension"
"github.com/openshift/origin/pkg/template/api"
)
func addConversionFuncs(scheme *runtime.Scheme) error {
if err := scheme.AddFieldLabelConversionFunc("v1", "Template",
oapi.GetFieldLabelConversionFunc(api.TemplateToSelectableFields(&api.Template{}), nil),
); err != nil {
return err
}
if err := scheme.AddFieldLabelConversionFunc("v1", "TemplateInstance",
oapi.GetFieldLabelConversionFunc(api.TemplateInstanceToSelectableFields(&api.TemplateInstance{}), nil),
); err != nil {
return err
}
if err := scheme.AddFieldLabelConversionFunc("v1", "BrokerTemplateInstance",
oapi.GetFieldLabelConversionFunc(api.BrokerTemplateInstanceToSelectableFields(&api.BrokerTemplateInstance{}), nil),
); err != nil {
return err
}
return nil
}
var _ runtime.NestedObjectDecoder = &Template{}
var _ runtime.NestedObjectEncoder = &Template{}
// DecodeNestedObjects decodes the object as a runtime.Unknown with JSON content.
func (c *Template) DecodeNestedObjects(d runtime.Decoder) error {
for i := range c.Objects {
if c.Objects[i].Object != nil {
continue
}
c.Objects[i].Object = &runtime.Unknown{
ContentType: "application/json",
Raw: c.Objects[i].Raw,
}
}
return nil
}
func (c *Template) EncodeNestedObjects(e runtime.Encoder) error {
for i := range c.Objects {
if err := extension.EncodeNestedRawExtension(runtime.UnstructuredJSONScheme, &c.Objects[i]); err != nil {
return err
}
}
return nil
}