Skip to content

Commit 49a84f8

Browse files
committed
removing blank lines per default and added keep-blank-lines option
1 parent 8c7ea8f commit 49a84f8

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ $ docker run -d --name nginx-gen --volumes-from nginx \
7777
### Usage
7878
```
7979
$ docker-gen
80-
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>]
80+
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>]
8181
```
8282

8383
*Options:*
@@ -92,7 +92,7 @@ Usage: docker-gen [-config file] [-watch=false] [-notify="restart xyz"] [-notify
9292
-notify-sighup="": send HUP signal to container. Equivalent to `docker kill -s HUP container-ID`
9393
-only-exposed=false: only include containers with exposed ports
9494
-only-published=false: only include containers with published ports (implies -only-exposed)
95-
-skip-blank-lines=false: skip blank lines in output file
95+
-keep-blank-lines=false: keep blank lines in the output file
9696
-tlscacert="": path to TLS CA certificate file
9797
-tlscert="": path to TLS client certificate file
9898
-tlskey="": path to TLS client key file

docker-gen.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
configFiles stringslice
3030
configs ConfigFile
3131
interval int
32-
skipBlankLines bool
32+
keepBlankLines bool
3333
endpoint string
3434
tlsCert string
3535
tlsKey string
@@ -115,7 +115,7 @@ type Config struct {
115115
OnlyExposed bool
116116
OnlyPublished bool
117117
Interval int
118-
SkipBlankLines bool
118+
KeepBlankLines bool
119119
}
120120

121121
type ConfigFile struct {
@@ -393,7 +393,7 @@ func initFlags() {
393393
"send HUP signal to container. Equivalent to `docker kill -s HUP container-ID`")
394394
flag.Var(&configFiles, "config", "config files with template directives. Config files will be merged if this option is specified multiple times.")
395395
flag.IntVar(&interval, "interval", 0, "notify command interval (secs)")
396-
flag.BoolVar(&skipBlankLines, "skip-blank-lines", false, "skip blank lines in output file")
396+
flag.BoolVar(&keepBlankLines, "keep-blank-lines", false, "keep blank lines in the output file")
397397
flag.StringVar(&endpoint, "endpoint", "", "docker api endpoint (tcp|unix://..). Default unix:///var/run/docker.sock")
398398
flag.StringVar(&tlsCert, "tlscert", filepath.Join(certPath, "cert.pem"), "path to TLS client certificate file")
399399
flag.StringVar(&tlsKey, "tlskey", filepath.Join(certPath, "key.pem"), "path to TLS client key file")
@@ -434,7 +434,7 @@ func main() {
434434
OnlyExposed: onlyExposed,
435435
OnlyPublished: onlyPublished,
436436
Interval: interval,
437-
SkipBlankLines: skipBlankLines,
437+
KeepBlankLines: keepBlankLines,
438438
}
439439
if notifySigHUPContainerID != "" {
440440
config.NotifyContainers[notifySigHUPContainerID] = docker.SIGHUP

template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ func generateFile(config Config, containers Context) bool {
382382

383383
contents := executeTemplate(config.Template, filteredContainers)
384384

385-
if config.SkipBlankLines {
385+
if !config.KeepBlankLines {
386386
contents = removeBlankLines(contents)
387387
}
388388

0 commit comments

Comments
 (0)