@@ -148,6 +148,123 @@ func TestMakeDeployment(t *testing.T) {
148
148
},
149
149
},
150
150
151
+ {
152
+ name : "valid container source with one container, labels are respected" ,
153
+ source : & v1.ContainerSource {
154
+ ObjectMeta : metav1.ObjectMeta {
155
+ Name : name ,
156
+ Namespace : "test-namespace" ,
157
+ UID : uid ,
158
+ },
159
+ Spec : v1.ContainerSourceSpec {
160
+ Template : corev1.PodTemplateSpec {
161
+ ObjectMeta : metav1.ObjectMeta {
162
+ Labels : map [string ]string {
163
+ "example" : "value" ,
164
+ },
165
+ },
166
+ Spec : corev1.PodSpec {
167
+ ServiceAccountName : "test-service-account" ,
168
+ Containers : []corev1.Container {
169
+ {
170
+ Name : "test-source" ,
171
+ Image : "test-image" ,
172
+ Args : []string {"--test1=args1" , "--test2=args2" },
173
+ Env : []corev1.EnvVar {
174
+ {
175
+ Name : "test1" ,
176
+ Value : "arg1" ,
177
+ },
178
+ {
179
+ Name : "test2" ,
180
+ ValueFrom : & corev1.EnvVarSource {
181
+ SecretKeyRef : & corev1.SecretKeySelector {
182
+ Key : "test2-secret" ,
183
+ },
184
+ },
185
+ },
186
+ },
187
+ ImagePullPolicy : corev1 .PullIfNotPresent ,
188
+ },
189
+ },
190
+ },
191
+ },
192
+ SourceSpec : duckv1.SourceSpec {
193
+ Sink : duckv1.Destination {
194
+ URI : apis .HTTP ("test-sink" ),
195
+ },
196
+ },
197
+ },
198
+ },
199
+ want : & appsv1.Deployment {
200
+ TypeMeta : metav1.TypeMeta {
201
+ APIVersion : "apps/v1" ,
202
+ Kind : "Deployment" ,
203
+ },
204
+ ObjectMeta : metav1.ObjectMeta {
205
+ Name : fmt .Sprintf ("%s-deployment" , name ),
206
+ Namespace : "test-namespace" ,
207
+ OwnerReferences : []metav1.OwnerReference {{
208
+ APIVersion : "sources.knative.dev/v1" ,
209
+ Kind : "ContainerSource" ,
210
+ Name : name ,
211
+ UID : uid ,
212
+ Controller : & yes ,
213
+ BlockOwnerDeletion : & yes ,
214
+ }},
215
+ Labels : map [string ]string {
216
+ "sources.knative.dev/containerSource" : name ,
217
+ "sources.knative.dev/source" : "container-source-controller" ,
218
+ "example" : "value" ,
219
+ },
220
+ },
221
+ Spec : appsv1.DeploymentSpec {
222
+ Selector : & metav1.LabelSelector {
223
+ MatchLabels : map [string ]string {
224
+ "sources.knative.dev/containerSource" : name ,
225
+ "sources.knative.dev/source" : "container-source-controller" ,
226
+ "example" : "value" ,
227
+ },
228
+ },
229
+ Template : corev1.PodTemplateSpec {
230
+ ObjectMeta : metav1.ObjectMeta {
231
+ Labels : map [string ]string {
232
+ "sources.knative.dev/containerSource" : name ,
233
+ "sources.knative.dev/source" : "container-source-controller" ,
234
+ "example" : "value" ,
235
+ },
236
+ },
237
+ Spec : corev1.PodSpec {
238
+ ServiceAccountName : "test-service-account" ,
239
+ Containers : []corev1.Container {
240
+ {
241
+ Name : "test-source" ,
242
+ Image : "test-image" ,
243
+ Args : []string {
244
+ "--test1=args1" ,
245
+ "--test2=args2" ,
246
+ },
247
+ Env : []corev1.EnvVar {
248
+ {
249
+ Name : "test1" ,
250
+ Value : "arg1" ,
251
+ }, {
252
+ Name : "test2" ,
253
+ ValueFrom : & corev1.EnvVarSource {
254
+ SecretKeyRef : & corev1.SecretKeySelector {
255
+ Key : "test2-secret" ,
256
+ },
257
+ },
258
+ }},
259
+ ImagePullPolicy : corev1 .PullIfNotPresent ,
260
+ },
261
+ },
262
+ },
263
+ },
264
+ },
265
+ },
266
+ },
267
+
151
268
{
152
269
name : "valid container source with two containers" ,
153
270
source : & v1.ContainerSource {
0 commit comments