@@ -15,6 +15,8 @@ import (
1515 docker "github.com/fsouza/go-dockerclient"
1616)
1717
18+ type stringslice []string
19+
1820var (
1921 buildVersion string
2022 version bool
2325 notifySigHUPContainerID string
2426 onlyExposed bool
2527 onlyPublished bool
26- configFile string
28+ configFiles stringslice
2729 configs ConfigFile
2830 interval int
2931 endpoint string
@@ -76,6 +78,16 @@ type SwarmNode struct {
7678 Address Address
7779}
7880
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+
7991func (i * DockerImage ) String () string {
8092 ret := i .Repository
8193 if i .Registry != "" {
@@ -337,7 +349,7 @@ func initFlags() {
337349 flag .BoolVar (& onlyPublished , "only-published" , false , "only include containers with published ports (implies -only-exposed)" )
338350 flag .StringVar (& notifyCmd , "notify" , "" , "run command after template is regenerated" )
339351 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. " )
341353 flag .IntVar (& interval , "interval" , 0 , "notify command interval (s)" )
342354 flag .StringVar (& endpoint , "endpoint" , "" , "docker api endpoint" )
343355 flag .StringVar (& tlsCert , "tlscert" , "" , "path to TLS client certificate file" )
@@ -355,15 +367,17 @@ func main() {
355367 return
356368 }
357369
358- if flag .NArg () < 1 && configFile == "" {
370+ if flag .NArg () < 1 && len ( configFiles ) == 0 {
359371 usage ()
360372 os .Exit (1 )
361373 }
362374
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+ }
367381 }
368382 } else {
369383 config := Config {
0 commit comments