summaryrefslogtreecommitdiffstats
path: root/lib/xdsconfig/config.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-10 12:19:34 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-16 14:27:28 +0200
commitdd6f08b10b1597f44e3dc25509ac9a45336b0914 (patch)
tree3dcb835306bc3adbae7c27d94fc8a51de8d6f09a /lib/xdsconfig/config.go
parent0262f5bef6ff67e77b844a04733c57740fba9f00 (diff)
Add folder interface and support native pathmap folder type.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/xdsconfig/config.go')
-rw-r--r--lib/xdsconfig/config.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/xdsconfig/config.go b/lib/xdsconfig/config.go
index f2d0710..a3e5a7e 100644
--- a/lib/xdsconfig/config.go
+++ b/lib/xdsconfig/config.go
@@ -2,7 +2,6 @@ package xdsconfig
import (
"fmt"
-
"os"
"github.com/Sirupsen/logrus"
@@ -16,13 +15,21 @@ type Config struct {
APIVersion string `json:"apiVersion"`
VersionGitTag string `json:"gitTag"`
Builder BuilderConfig `json:"builder"`
- Folders FoldersConfig `json:"folders"`
// Private (un-exported fields in REST GET /config route)
+ Options Options `json:"-"`
FileConf FileConfig `json:"-"`
Log *logrus.Logger `json:"-"`
}
+// Options set at the command line
+type Options struct {
+ ConfigFile string
+ LogLevel string
+ LogFile string
+ NoFolderConfig bool
+}
+
// Config default values
const (
DefaultAPIVersion = "1"
@@ -41,7 +48,13 @@ func Init(cliCtx *cli.Context, log *logrus.Logger) (*Config, error) {
APIVersion: DefaultAPIVersion,
VersionGitTag: cliCtx.App.Metadata["git-tag"].(string),
Builder: BuilderConfig{},
- Folders: FoldersConfig{},
+
+ Options: Options{
+ ConfigFile: cliCtx.GlobalString("config"),
+ LogLevel: cliCtx.GlobalString("log"),
+ LogFile: cliCtx.GlobalString("logfile"),
+ NoFolderConfig: cliCtx.GlobalBool("no-folderconfig"),
+ },
FileConf: FileConfig{
WebAppDir: "webapp/dist",
ShareRootDir: DefaultShareDir,
@@ -52,7 +65,7 @@ func Init(cliCtx *cli.Context, log *logrus.Logger) (*Config, error) {
}
// config file settings overwrite default config
- err = updateConfigFromFile(&c, cliCtx.GlobalString("config"))
+ err = readGlobalConfig(&c, c.Options.ConfigFile)
if err != nil {
return nil, err
}