/
dockertypes.go
191 lines (180 loc) · 6.06 KB
/
dockertypes.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package image
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/openshift/api/image/docker10"
public "github.com/openshift/origin/pkg/image/apis/image/docker10"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// DockerImage is the type representing a docker image and its various properties when
// retrieved from the Docker client API.
type DockerImage = docker10.DockerImage
// DockerConfig is the list of configuration options used when creating a container.
type DockerConfig = docker10.DockerConfig
// Convert_public_to_api_DockerImage ensures that out has all of the fields set from in or returns
// an error.
func Convert_public_to_api_DockerImage(in *public.DockerImage, out *docker10.DockerImage) error {
*out = docker10.DockerImage{
ID: in.ID,
Parent: in.Parent,
Comment: in.Comment,
Created: metav1.Time{Time: in.Created},
Container: in.Container,
DockerVersion: in.DockerVersion,
Author: in.Author,
Architecture: in.Architecture,
Size: in.Size,
}
if err := Convert_public_to_api_DockerConfig(&in.ContainerConfig, &out.ContainerConfig); err != nil {
return err
}
if in.Config != nil {
out.Config = &docker10.DockerConfig{}
if err := Convert_public_to_api_DockerConfig(in.Config, out.Config); err != nil {
return err
}
}
return nil
}
// Convert_imageconfig_to_api_DockerImage takes a Docker registry digest (schema 2.1) and converts it
// to the external API version of Image.
func Convert_compatibility_to_api_DockerImage(in *public.DockerV1CompatibilityImage, out *docker10.DockerImage) error {
*out = docker10.DockerImage{
ID: in.ID,
Parent: in.Parent,
Comment: in.Comment,
Created: metav1.Time{Time: in.Created},
Container: in.Container,
DockerVersion: in.DockerVersion,
Author: in.Author,
Architecture: in.Architecture,
Size: in.Size,
}
if err := Convert_public_to_api_DockerConfig(&in.ContainerConfig, &out.ContainerConfig); err != nil {
return err
}
if in.Config != nil {
out.Config = &docker10.DockerConfig{}
if err := Convert_public_to_api_DockerConfig(in.Config, out.Config); err != nil {
return err
}
}
return nil
}
// Convert_imageconfig_to_api_DockerImage takes a Docker registry digest (schema 2.2) and converts it
// to the external API version of Image.
func Convert_imageconfig_to_api_DockerImage(in *public.DockerImageConfig, out *docker10.DockerImage) error {
*out = docker10.DockerImage{
ID: in.ID,
Parent: in.Parent,
Comment: in.Comment,
Created: metav1.Time{Time: in.Created},
Container: in.Container,
DockerVersion: in.DockerVersion,
Author: in.Author,
Architecture: in.Architecture,
Size: in.Size,
}
if err := Convert_public_to_api_DockerConfig(&in.ContainerConfig, &out.ContainerConfig); err != nil {
return err
}
if in.Config != nil {
out.Config = &docker10.DockerConfig{}
if err := Convert_public_to_api_DockerConfig(in.Config, out.Config); err != nil {
return err
}
}
return nil
}
// Convert_api_to_public_DockerImage ensures that out has all of the fields set from in or returns
// an error.
func Convert_api_to_public_DockerImage(in *docker10.DockerImage, out *public.DockerImage) error {
*out = public.DockerImage{
ID: in.ID,
Parent: in.Parent,
Comment: in.Comment,
Created: in.Created.Time,
Container: in.Container,
DockerVersion: in.DockerVersion,
Author: in.Author,
Architecture: in.Architecture,
Size: in.Size,
}
if err := Convert_api_to_public_DockerConfig(&in.ContainerConfig, &out.ContainerConfig); err != nil {
return err
}
if in.Config != nil {
out.Config = &public.DockerConfig{}
if err := Convert_api_to_public_DockerConfig(in.Config, out.Config); err != nil {
return err
}
}
return nil
}
// Convert_public_to_api_DockerConfig ensures that out has all of the fields set from in or returns
// an error.
func Convert_public_to_api_DockerConfig(in *public.DockerConfig, out *docker10.DockerConfig) error {
*out = docker10.DockerConfig{
Hostname: in.Hostname,
Domainname: in.Domainname,
User: in.User,
Memory: in.Memory,
MemorySwap: in.MemorySwap,
CPUShares: in.CPUShares,
CPUSet: in.CPUSet,
AttachStdin: in.AttachStdin,
AttachStdout: in.AttachStdout,
AttachStderr: in.AttachStderr,
PortSpecs: in.PortSpecs,
ExposedPorts: in.ExposedPorts,
Tty: in.Tty,
OpenStdin: in.OpenStdin,
StdinOnce: in.StdinOnce,
Env: in.Env,
Cmd: in.Cmd,
DNS: in.DNS,
Image: in.Image,
Volumes: in.Volumes,
VolumesFrom: in.VolumesFrom,
WorkingDir: in.WorkingDir,
Entrypoint: in.Entrypoint,
NetworkDisabled: in.NetworkDisabled,
SecurityOpts: in.SecurityOpts,
OnBuild: in.OnBuild,
Labels: in.Labels,
}
return nil
}
// Convert_api_to_public_DockerConfig ensures that out has all of the fields set from in or returns
// an error.
func Convert_api_to_public_DockerConfig(in *docker10.DockerConfig, out *public.DockerConfig) error {
*out = public.DockerConfig{
Hostname: in.Hostname,
Domainname: in.Domainname,
User: in.User,
Memory: in.Memory,
MemorySwap: in.MemorySwap,
CPUShares: in.CPUShares,
CPUSet: in.CPUSet,
AttachStdin: in.AttachStdin,
AttachStdout: in.AttachStdout,
AttachStderr: in.AttachStderr,
PortSpecs: in.PortSpecs,
ExposedPorts: in.ExposedPorts,
Tty: in.Tty,
OpenStdin: in.OpenStdin,
StdinOnce: in.StdinOnce,
Env: in.Env,
Cmd: in.Cmd,
DNS: in.DNS,
Image: in.Image,
Volumes: in.Volumes,
VolumesFrom: in.VolumesFrom,
WorkingDir: in.WorkingDir,
Entrypoint: in.Entrypoint,
NetworkDisabled: in.NetworkDisabled,
SecurityOpts: in.SecurityOpts,
OnBuild: in.OnBuild,
Labels: in.Labels,
}
return nil
}