8460: Add default config and -dump-config flag.
authorTom Clegg <tom@curoverse.com>
Sun, 13 Nov 2016 22:14:18 +0000 (17:14 -0500)
committerTom Clegg <tom@curoverse.com>
Sun, 13 Nov 2016 22:14:18 +0000 (17:14 -0500)
sdk/go/config/load.go
services/ws/config.go
services/ws/main.go

index 9c65d65e84a57d9120d69dd84912615ff3949e35..2bbb440fb31211241a78a6f15c788f7e4d706334 100644 (file)
@@ -22,3 +22,8 @@ func LoadFile(cfg interface{}, configPath string) error {
        }
        return nil
 }
+
+// Dump returns a YAML representation of cfg.
+func Dump(cfg interface{}) ([]byte, error) {
+       return yaml.Marshal(cfg)
+}
index fbdedb53ad7746512586b0149b487615855cca79..60731f9b23d4876f988ab560c757c26bfd6716d5 100644 (file)
@@ -15,6 +15,17 @@ type Config struct {
 
 func DefaultConfig() Config {
        return Config{
+               Client: arvados.Client{
+                       APIHost: "localhost:443",
+               },
+               Postgres: pgConfig{
+                       "dbname":          "arvados_test",
+                       "user":            "arvados",
+                       "password":        "xyzzy",
+                       "host":            "localhost",
+                       "connect_timeout": "30",
+                       "sslmode":         "disable",
+               },
                ClientEventQueue: 64,
        }
 }
index ce56d0d5fddc32973da04de855f74102bf66212a..9a24b312b05344c07a4331b7652199a379f82869 100644 (file)
@@ -2,6 +2,7 @@ package main
 
 import (
        "flag"
+       "fmt"
        "log"
        "net/http"
        "time"
@@ -11,12 +12,24 @@ import (
 
 func main() {
        configPath := flag.String("config", "/etc/arvados/ws/ws.yml", "`path` to config file")
+       dumpConfig := flag.Bool("dump-config", false, "show current configuration and exit")
        cfg := DefaultConfig()
+       flag.Parse()
+
        err := config.LoadFile(&cfg, *configPath)
        if err != nil {
                log.Fatal(err)
        }
 
+       if *dumpConfig {
+               txt, err := config.Dump(&cfg)
+               if err != nil {
+                       log.Fatal(err)
+               }
+               fmt.Print(string(txt))
+               return
+       }
+
        srv := &http.Server{
                Addr:           cfg.Listen,
                ReadTimeout:    time.Minute,