Skip to content

Commit

Permalink
removing blank lines per default and added keep-blank-lines option
Browse files Browse the repository at this point in the history
  • Loading branch information
webner committed Jul 26, 2015
1 parent 8c7ea8f commit 49a84f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ $ docker run -d --name nginx-gen --volumes-from nginx \
### Usage
```
$ docker-gen
Usage: docker-gen [-config file] [-watch=false] [-notify="restart xyz"] [-notify-sighup="nginx-proxy"] [-interval=0] [-endpoint tcp|unix://..] [-tlsverify] [-tlscert file] [-tlskey file] [-tlscacert file] [-skip-blank-lines] <template> [<dest>]
Usage: docker-gen [-config file] [-watch=false] [-notify="restart xyz"] [-notify-sighup="nginx-proxy"] [-interval=0] [-endpoint tcp|unix://..] [-tlsverify] [-tlscert file] [-tlskey file] [-tlscacert file] [-keep-blank-lines] <template> [<dest>]
```

*Options:*
Expand All @@ -92,7 +92,7 @@ Usage: docker-gen [-config file] [-watch=false] [-notify="restart xyz"] [-notify
-notify-sighup="": send HUP signal to container. Equivalent to `docker kill -s HUP container-ID`
-only-exposed=false: only include containers with exposed ports
-only-published=false: only include containers with published ports (implies -only-exposed)
-skip-blank-lines=false: skip blank lines in output file
-keep-blank-lines=false: keep blank lines in the output file
-tlscacert="": path to TLS CA certificate file
-tlscert="": path to TLS client certificate file
-tlskey="": path to TLS client key file
Expand Down
8 changes: 4 additions & 4 deletions docker-gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
configFiles stringslice
configs ConfigFile
interval int
skipBlankLines bool
keepBlankLines bool
endpoint string
tlsCert string
tlsKey string
Expand Down Expand Up @@ -115,7 +115,7 @@ type Config struct {
OnlyExposed bool
OnlyPublished bool
Interval int
SkipBlankLines bool
KeepBlankLines bool
}

type ConfigFile struct {
Expand Down Expand Up @@ -393,7 +393,7 @@ func initFlags() {
"send HUP signal to container. Equivalent to `docker kill -s HUP container-ID`")
flag.Var(&configFiles, "config", "config files with template directives. Config files will be merged if this option is specified multiple times.")
flag.IntVar(&interval, "interval", 0, "notify command interval (secs)")
flag.BoolVar(&skipBlankLines, "skip-blank-lines", false, "skip blank lines in output file")
flag.BoolVar(&keepBlankLines, "keep-blank-lines", false, "keep blank lines in the output file")
flag.StringVar(&endpoint, "endpoint", "", "docker api endpoint (tcp|unix://..). Default unix:///var/run/docker.sock")
flag.StringVar(&tlsCert, "tlscert", filepath.Join(certPath, "cert.pem"), "path to TLS client certificate file")
flag.StringVar(&tlsKey, "tlskey", filepath.Join(certPath, "key.pem"), "path to TLS client key file")
Expand Down Expand Up @@ -434,7 +434,7 @@ func main() {
OnlyExposed: onlyExposed,
OnlyPublished: onlyPublished,
Interval: interval,
SkipBlankLines: skipBlankLines,
KeepBlankLines: keepBlankLines,
}
if notifySigHUPContainerID != "" {
config.NotifyContainers[notifySigHUPContainerID] = docker.SIGHUP
Expand Down
2 changes: 1 addition & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func generateFile(config Config, containers Context) bool {

contents := executeTemplate(config.Template, filteredContainers)

if config.SkipBlankLines {
if !config.KeepBlankLines {
contents = removeBlankLines(contents)
}

Expand Down

0 comments on commit 49a84f8

Please sign in to comment.