File tree Expand file tree Collapse file tree 5 files changed +280
-112
lines changed Expand file tree Collapse file tree 5 files changed +280
-112
lines changed Original file line number Diff line number Diff line change @@ -3509,3 +3509,49 @@ services:
3509
3509
},
3510
3510
})
3511
3511
}
3512
+
3513
+ func TestLoadServiceHooks (t * testing.T ) {
3514
+ p , err := loadYAML (`
3515
+ name: load-service-hooks
3516
+ services:
3517
+ test:
3518
+ post_start:
3519
+ - command: echo start
3520
+ user: root
3521
+ privileged: true
3522
+ working_dir: /
3523
+ environment:
3524
+ - FOO=BAR
3525
+ pre_stop:
3526
+ - command: echo stop
3527
+ user: root
3528
+ working_dir: /
3529
+ environment:
3530
+ FOO: BAR
3531
+
3532
+ ` )
3533
+ assert .NilError (t , err )
3534
+ start := p .Services ["test" ].PostStart
3535
+ assert .DeepEqual (t , start , []types.ServiceHook {
3536
+ {
3537
+ Command : types.ShellCommand {"echo" , "start" },
3538
+ User : "root" ,
3539
+ Privileged : true ,
3540
+ WorkingDir : "/" ,
3541
+ Environment : types.MappingWithEquals {
3542
+ "FOO" : strPtr ("BAR" ),
3543
+ },
3544
+ },
3545
+ })
3546
+ stop := p .Services ["test" ].PreStop
3547
+ assert .DeepEqual (t , stop , []types.ServiceHook {
3548
+ {
3549
+ Command : types.ShellCommand {"echo" , "stop" },
3550
+ User : "root" ,
3551
+ WorkingDir : "/" ,
3552
+ Environment : types.MappingWithEquals {
3553
+ "FOO" : strPtr ("BAR" ),
3554
+ },
3555
+ },
3556
+ })
3557
+ }
Original file line number Diff line number Diff line change 370
370
},
371
371
"uniqueItems" : true
372
372
},
373
+ "post_start" : {"type" : " array" , "items" : {"$ref" : " #/definitions/service_hook" }},
374
+ "pre_stop" : {"type" : " array" , "items" : {"$ref" : " #/definitions/service_hook" }},
373
375
"privileged" : {"type" : [" boolean" , " string" ]},
374
376
"profiles" : {"$ref" : " #/definitions/list_of_strings" },
375
377
"pull_policy" : {"type" : " string" , "enum" : [
816
818
]
817
819
},
818
820
821
+ "service_hook" : {
822
+ "id" : " #/definitions/service_hook" ,
823
+ "type" : " object" ,
824
+ "properties" : {
825
+ "command" : {"$ref" : " #/definitions/command" },
826
+ "user" : {"type" : " string" },
827
+ "privileged" : {"type" : [" boolean" , " string" ]},
828
+ "working_dir" : {"type" : " string" },
829
+ "environment" : {"$ref" : " #/definitions/list_or_dict" }
830
+ },
831
+ "additionalProperties" : false ,
832
+ "patternProperties" : {"^x-" : {}}
833
+ },
834
+
819
835
"env_file" : {
820
836
"oneOf" : [
821
837
{"type" : " string" },
You can’t perform that action at this time.
0 commit comments