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