forked from tektoncd/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer_conversion.go
160 lines (149 loc) · 4.83 KB
/
container_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
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
package v1beta1
import (
"context"
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
)
func (s Step) convertTo(ctx context.Context, sink *v1.Step) {
sink.Name = s.Name
sink.Image = s.Image
sink.Command = s.Command
sink.Args = s.Args
sink.WorkingDir = s.WorkingDir
sink.EnvFrom = s.EnvFrom
sink.Env = s.Env
sink.ComputeResources = s.Resources
sink.VolumeMounts = s.VolumeMounts
sink.VolumeDevices = s.VolumeDevices
sink.ImagePullPolicy = s.ImagePullPolicy
sink.SecurityContext = s.SecurityContext
sink.Script = s.Script
sink.Timeout = s.Timeout
sink.Workspaces = nil
for _, w := range s.Workspaces {
new := v1.WorkspaceUsage{}
w.convertTo(ctx, &new)
sink.Workspaces = append(sink.Workspaces, new)
}
sink.OnError = (v1.OnErrorType)(s.OnError)
sink.StdoutConfig = (*v1.StepOutputConfig)(s.StdoutConfig)
sink.StderrConfig = (*v1.StepOutputConfig)(s.StderrConfig)
// TODO(#4546): Handle deprecated fields
// Ports, LivenessProbe, ReadinessProbe, StartupProbe, Lifecycle, TerminationMessagePath
// TerminationMessagePolicy, Stdin, StdinOnce, TTY
}
func (s *Step) convertFrom(ctx context.Context, source v1.Step) {
s.Name = source.Name
s.Image = source.Image
s.Command = source.Command
s.Args = source.Args
s.WorkingDir = source.WorkingDir
s.EnvFrom = source.EnvFrom
s.Env = source.Env
s.Resources = source.ComputeResources
s.VolumeMounts = source.VolumeMounts
s.VolumeDevices = source.VolumeDevices
s.ImagePullPolicy = source.ImagePullPolicy
s.SecurityContext = source.SecurityContext
s.Script = source.Script
s.Timeout = source.Timeout
s.Workspaces = nil
for _, w := range source.Workspaces {
new := WorkspaceUsage{}
new.convertFrom(ctx, w)
s.Workspaces = append(s.Workspaces, new)
}
s.OnError = (OnErrorType)(source.OnError)
s.StdoutConfig = (*StepOutputConfig)(source.StdoutConfig)
s.StderrConfig = (*StepOutputConfig)(source.StderrConfig)
}
func (s StepTemplate) convertTo(ctx context.Context, sink *v1.StepTemplate) {
sink.Image = s.Image
sink.Command = s.Command
sink.Args = s.Args
sink.WorkingDir = s.WorkingDir
sink.EnvFrom = s.EnvFrom
sink.Env = s.Env
sink.ComputeResources = s.Resources
sink.VolumeMounts = s.VolumeMounts
sink.VolumeDevices = s.VolumeDevices
sink.ImagePullPolicy = s.ImagePullPolicy
sink.SecurityContext = s.SecurityContext
// TODO(#4546): Handle deprecated fields
// Name, Ports, LivenessProbe, ReadinessProbe, StartupProbe, Lifecycle, TerminationMessagePath
// TerminationMessagePolicy, Stdin, StdinOnce, TTY
}
func (s *StepTemplate) convertFrom(ctx context.Context, source *v1.StepTemplate) {
s.Image = source.Image
s.Command = source.Command
s.Args = source.Args
s.WorkingDir = source.WorkingDir
s.EnvFrom = source.EnvFrom
s.Env = source.Env
s.Resources = source.ComputeResources
s.VolumeMounts = source.VolumeMounts
s.VolumeDevices = source.VolumeDevices
s.ImagePullPolicy = source.ImagePullPolicy
s.SecurityContext = source.SecurityContext
}
func (s Sidecar) convertTo(ctx context.Context, sink *v1.Sidecar) {
sink.Name = s.Name
sink.Image = s.Image
sink.Command = s.Command
sink.Args = s.Args
sink.WorkingDir = s.WorkingDir
sink.Ports = s.Ports
sink.EnvFrom = s.EnvFrom
sink.Env = s.Env
sink.ComputeResources = s.Resources
sink.VolumeMounts = s.VolumeMounts
sink.VolumeDevices = s.VolumeDevices
sink.LivenessProbe = s.LivenessProbe
sink.ReadinessProbe = s.ReadinessProbe
sink.StartupProbe = s.StartupProbe
sink.Lifecycle = s.Lifecycle
sink.TerminationMessagePath = s.TerminationMessagePath
sink.TerminationMessagePolicy = s.TerminationMessagePolicy
sink.ImagePullPolicy = s.ImagePullPolicy
sink.SecurityContext = s.SecurityContext
sink.Stdin = s.Stdin
sink.StdinOnce = s.StdinOnce
sink.TTY = s.TTY
sink.Script = s.Script
sink.Workspaces = nil
for _, w := range s.Workspaces {
new := v1.WorkspaceUsage{}
w.convertTo(ctx, &new)
sink.Workspaces = append(sink.Workspaces, new)
}
}
func (s *Sidecar) convertFrom(ctx context.Context, source v1.Sidecar) {
s.Name = source.Name
s.Image = source.Image
s.Command = source.Command
s.Args = source.Args
s.WorkingDir = source.WorkingDir
s.Ports = source.Ports
s.EnvFrom = source.EnvFrom
s.Env = source.Env
s.Resources = source.ComputeResources
s.VolumeMounts = source.VolumeMounts
s.VolumeDevices = source.VolumeDevices
s.LivenessProbe = source.LivenessProbe
s.ReadinessProbe = source.ReadinessProbe
s.StartupProbe = source.StartupProbe
s.Lifecycle = source.Lifecycle
s.TerminationMessagePath = source.TerminationMessagePath
s.TerminationMessagePolicy = source.TerminationMessagePolicy
s.ImagePullPolicy = source.ImagePullPolicy
s.SecurityContext = source.SecurityContext
s.Stdin = source.Stdin
s.StdinOnce = source.StdinOnce
s.TTY = source.TTY
s.Script = source.Script
s.Workspaces = nil
for _, w := range source.Workspaces {
new := WorkspaceUsage{}
new.convertFrom(ctx, w)
s.Workspaces = append(s.Workspaces, new)
}
}