minio: Add config-folder option.

Fixes #997
This commit is contained in:
Harshavardhana
2015-12-06 14:31:20 -08:00
parent a97c4ebce3
commit 836f5204af
19 changed files with 149 additions and 202 deletions
+22 -4
View File
@@ -19,6 +19,7 @@ package main
import (
"fmt"
"os"
"os/user"
"runtime"
"strconv"
@@ -55,9 +56,9 @@ func init() {
checkGolangRuntimeVersion()
// Check for the environment early on and gracefuly report.
_, err := userCurrent()
_, err := user.Current()
if err != nil {
Fatalf("Unable to obtain user's home directory. \nError: %s\n", err)
}
if os.Getenv("DOCKERIMAGE") == "1" {
@@ -118,6 +119,7 @@ func registerApp() *cli.App {
registerCommand(updateCmd)
// register all flags
registerFlag(configFolderFlag)
registerFlag(addressFlag)
registerFlag(accessLogFlag)
registerFlag(rateLimitFlag)
@@ -146,10 +148,19 @@ func registerApp() *cli.App {
}
Fatalln(msg)
}
return app
}
func checkMainSyntax(c *cli.Context) {
configPath, err := getConfigPath()
if err != nil {
Fatalf("Unable to obtain user's home directory. \nError: %s\n", err)
}
if configPath == "" {
Fatalf("Config folder cannot be empty, please specify --config-folder <foldername>.")
}
}
func main() {
probe.Init() // Set project's root source path.
probe.SetAppInfo("Release-Tag", minioReleaseTag)
@@ -160,8 +171,15 @@ func main() {
app := registerApp()
app.Before = func(c *cli.Context) error {
globalJSONFlag = c.GlobalBool("json")
// Sets new config folder.
setGlobalConfigPath(c.GlobalString("config-folder"))
// Valid input arguments to main.
checkMainSyntax(c)
// Migrate any old version of config / state files to newer format.
migrate()
return nil
}
app.ExtraInfo = func() map[string]string {