author | Alberto Bertogli
<albertito@blitiri.com.ar> 2020-06-17 19:08:06 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2020-06-17 19:08:06 UTC |
parent | 50563e3efbc82c5851ebc41feef050c44d9e3835 |
gofer.go | +11 | -0 |
test/test.sh | +7 | -0 |
diff --git a/gofer.go b/gofer.go index 6f003b1..68ff250 100644 --- a/gofer.go +++ b/gofer.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "os" "os/signal" "syscall" @@ -19,6 +20,8 @@ var ( configFile = flag.String("configfile", "gofer.yaml", "Configuration file") configCheck = flag.Bool("configcheck", false, "Check the configuration and exit afterwards") + configPrint = flag.Bool("configprint", false, + "Check the configuration, print it, and exit afterwards") ) func main() { @@ -37,6 +40,14 @@ func main() { } log.Fatalf("invalid configuration") } + if *configPrint { + s, err := conf.ToString() + if err != nil { + log.Fatalf("%v", err) + } + fmt.Print(s) + return + } if *configCheck { log.Infof("config ok") return diff --git a/test/test.sh b/test/test.sh index c474a52..a0c3d3d 100755 --- a/test/test.sh +++ b/test/test.sh @@ -48,6 +48,13 @@ if ! gofer -configfile=.be-debug-conf -configcheck; then exit 1 fi +gofer -configfile=01-be.yaml -configprint > .be-print-conf +if diff -q 01-be.yaml .be-print-conf; then + echo "Printed and debug configs differ:" + diff 01-be.yaml .be-print-conf + exit 1 +fi + # Common tests, for both servers. for base in \