@@ -221,6 +221,73 @@ services:
221
221
}
222
222
}
223
223
224
+ func TestGloballyBinaryMount (t * testing.T ) {
225
+ composeFile := `
226
+ services:
227
+ web:
228
+ image: nginx
229
+ volumes:
230
+ - ./images:/var/www/foo
231
+ labels:
232
+ %[1]s/configmap-files: |-
233
+ - ./images
234
+ `
235
+ composeFile = fmt .Sprintf (composeFile , labels .KatenaryLabelPrefix )
236
+ tmpDir := setup (composeFile )
237
+ log .Println (tmpDir )
238
+ defer teardown (tmpDir )
239
+
240
+ os .Mkdir (filepath .Join (tmpDir , "images" ), 0o755 )
241
+
242
+ // create a png image
243
+ pngFile := tmpDir + "/images/foo.png"
244
+ w , h := 100 , 100
245
+ img := image .NewRGBA (image .Rect (0 , 0 , w , h ))
246
+ red := color.RGBA {255 , 0 , 0 , 255 }
247
+ for y := 0 ; y < h ; y ++ {
248
+ for x := 0 ; x < w ; x ++ {
249
+ img .Set (x , y , red )
250
+ }
251
+ }
252
+
253
+ blue := color.RGBA {0 , 0 , 255 , 255 }
254
+ for y := 30 ; y < 70 ; y ++ {
255
+ for x := 30 ; x < 70 ; x ++ {
256
+ img .Set (x , y , blue )
257
+ }
258
+ }
259
+ currentDir , _ := os .Getwd ()
260
+ os .Chdir (tmpDir )
261
+ defer os .Chdir (currentDir )
262
+
263
+ f , err := os .Create (pngFile )
264
+ if err != nil {
265
+ t .Fatal (err )
266
+ }
267
+ png .Encode (f , img )
268
+ f .Close ()
269
+ output := internalCompileTest (t , "-s" , "templates/web/deployment.yaml" )
270
+ d := v1.Deployment {}
271
+ yaml .Unmarshal ([]byte (output ), & d )
272
+ volumes := d .Spec .Template .Spec .Volumes
273
+ if len (volumes ) != 1 {
274
+ t .Errorf ("Expected 1 volume, got %d" , len (volumes ))
275
+ }
276
+
277
+ cm := corev1.ConfigMap {}
278
+ cmContent , err := helmTemplate (ConvertOptions {
279
+ OutputDir : "chart" ,
280
+ }, "-s" , "templates/web/statics/images/configmap.yaml" )
281
+ yaml .Unmarshal ([]byte (cmContent ), & cm )
282
+ if im , ok := cm .BinaryData ["foo.png" ]; ! ok {
283
+ t .Errorf ("Expected foo.png to be in the configmap" )
284
+ } else {
285
+ if len (im ) == 0 {
286
+ t .Errorf ("Expected image to be non-empty" )
287
+ }
288
+ }
289
+ }
290
+
224
291
func TestBindFrom (t * testing.T ) {
225
292
composeFile := `
226
293
services:
0 commit comments