@@ -15,6 +15,8 @@ import (
15
15
docker "github.com/fsouza/go-dockerclient"
16
16
)
17
17
18
+ type stringslice []string
19
+
18
20
var (
19
21
buildVersion string
20
22
version bool
23
25
notifySigHUPContainerID string
24
26
onlyExposed bool
25
27
onlyPublished bool
26
- configFile string
28
+ configFiles stringslice
27
29
configs ConfigFile
28
30
interval int
29
31
endpoint string
@@ -76,6 +78,16 @@ type SwarmNode struct {
76
78
Address Address
77
79
}
78
80
81
+ func (strings * stringslice ) String () string {
82
+ return "[]"
83
+ }
84
+
85
+ func (strings * stringslice ) Set (value string ) error {
86
+ // TODO: Throw an error for duplicate `dest`
87
+ * strings = append (* strings , value )
88
+ return nil
89
+ }
90
+
79
91
func (i * DockerImage ) String () string {
80
92
ret := i .Repository
81
93
if i .Registry != "" {
@@ -337,7 +349,7 @@ func initFlags() {
337
349
flag .BoolVar (& onlyPublished , "only-published" , false , "only include containers with published ports (implies -only-exposed)" )
338
350
flag .StringVar (& notifyCmd , "notify" , "" , "run command after template is regenerated" )
339
351
flag .StringVar (& notifySigHUPContainerID , "notify-sighup" , "" , "send HUP signal to container. Equivalent to `docker kill -s HUP container-ID`" )
340
- flag .StringVar ( & configFile , "config" , "" , " config file with template directives" )
352
+ flag .Var ( & configFiles , "config" , "config files with template directives. Config files will be merged if this option is specified multiple times. " )
341
353
flag .IntVar (& interval , "interval" , 0 , "notify command interval (s)" )
342
354
flag .StringVar (& endpoint , "endpoint" , "" , "docker api endpoint" )
343
355
flag .StringVar (& tlsCert , "tlscert" , "" , "path to TLS client certificate file" )
@@ -355,15 +367,17 @@ func main() {
355
367
return
356
368
}
357
369
358
- if flag .NArg () < 1 && configFile == "" {
370
+ if flag .NArg () < 1 && len ( configFiles ) == 0 {
359
371
usage ()
360
372
os .Exit (1 )
361
373
}
362
374
363
- if configFile != "" {
364
- err := loadConfig (configFile )
365
- if err != nil {
366
- log .Fatalf ("error loading config %s: %s\n " , configFile , err )
375
+ if len (configFiles ) > 0 {
376
+ for _ , configFile := range configFiles {
377
+ err := loadConfig (configFile )
378
+ if err != nil {
379
+ log .Fatalf ("error loading config %s: %s\n " , configFile , err )
380
+ }
367
381
}
368
382
} else {
369
383
config := Config {
0 commit comments