forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
conversion.go
55 lines (52 loc) · 1.61 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
package api
import (
"github.com/fsouza/go-dockerclient"
kapi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/conversion"
)
func init() {
err := kapi.Scheme.AddConversionFuncs(
// Convert docker client object to internal object
func(in *docker.Image, out *DockerImage, s conversion.Scope) error {
if err := s.Convert(&in.Config, &out.Config, conversion.AllowDifferentFieldTypeNames); err != nil {
return err
}
if err := s.Convert(&in.ContainerConfig, &out.ContainerConfig, conversion.AllowDifferentFieldTypeNames); err != nil {
return err
}
out.ID = in.ID
out.Parent = in.Parent
out.Comment = in.Comment
out.Created = unversioned.NewTime(in.Created)
out.Container = in.Container
out.DockerVersion = in.DockerVersion
out.Author = in.Author
out.Architecture = in.Architecture
out.Size = in.Size
return nil
},
func(in *DockerImage, out *docker.Image, s conversion.Scope) error {
if err := s.Convert(&in.Config, &out.Config, conversion.AllowDifferentFieldTypeNames); err != nil {
return err
}
if err := s.Convert(&in.ContainerConfig, &out.ContainerConfig, conversion.AllowDifferentFieldTypeNames); err != nil {
return err
}
out.ID = in.ID
out.Parent = in.Parent
out.Comment = in.Comment
out.Created = in.Created.Time
out.Container = in.Container
out.DockerVersion = in.DockerVersion
out.Author = in.Author
out.Architecture = in.Architecture
out.Size = in.Size
return nil
},
)
if err != nil {
// If one of the conversion functions is malformed, detect it immediately.
panic(err)
}
}