8 "github.com/Sirupsen/logrus"
9 "github.com/codegangsta/cli"
12 // Config parameters (json format) of /config command
14 Version string `json:"version"`
15 APIVersion string `json:"apiVersion"`
16 VersionGitTag string `json:"gitTag"`
18 // Private / un-exported fields
19 HTTPPort string `json:"-"`
24 // Config default values
26 DefaultAPIVersion = "1"
28 DefaultLogLevel = "error"
31 // Init loads the configuration on start-up
32 func Init(ctx *cli.Context, log *logrus.Logger) (Config, error) {
35 // Define default configuration
37 Version: ctx.App.Metadata["version"].(string),
38 APIVersion: DefaultAPIVersion,
39 VersionGitTag: ctx.App.Metadata["git-tag"].(string),
41 HTTPPort: DefaultPort,
45 // config file settings overwrite default config
46 c.FileConf, err = updateConfigFromFile(&c, ctx.GlobalString("config"))
54 // UpdateAll Update the current configuration
55 func (c *Config) UpdateAll(newCfg Config) error {
56 return fmt.Errorf("Not Supported")
59 func dirExists(path string) bool {
60 _, err := os.Stat(path)
61 if os.IsNotExist(err) {