forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conversion.go
40 lines (35 loc) · 1.08 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
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 {
return scheme.AddFieldLabelConversionFunc("v1", "Template",
oapi.GetFieldLabelConversionFunc(api.TemplateToSelectableFields(&api.Template{}), 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
}