mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
Revert "init: Honor config-dir flag when it is passed as global or local flag (#3337)"
This reverts commit e2ef95af7d
.
This is reverted since the previous patch caused crashes.
This commit is contained in:
parent
12c1abed98
commit
dd74e5a809
@ -53,12 +53,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
globalQuiet = false // quiet flag set via command line.
|
globalQuiet = false // Quiet flag set via command line.
|
||||||
globalConfigDir = mustGetConfigPath() // config-dir flag set via command line
|
|
||||||
// Add new global flags here.
|
|
||||||
|
|
||||||
globalIsDistXL = false // "Is Distributed?" flag.
|
globalIsDistXL = false // "Is Distributed?" flag.
|
||||||
|
|
||||||
|
// Add new global flags here.
|
||||||
|
|
||||||
// Maximum cache size.
|
// Maximum cache size.
|
||||||
globalMaxCacheSize = uint64(maxCacheSize)
|
globalMaxCacheSize = uint64(maxCacheSize)
|
||||||
// Cache expiry.
|
// Cache expiry.
|
||||||
|
128
cmd/main.go
128
cmd/main.go
@ -148,84 +148,70 @@ func checkMainSyntax(c *cli.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse command arguments and set global variables accordingly
|
|
||||||
func setGlobalsFromContext(c *cli.Context) {
|
|
||||||
// Set config dir
|
|
||||||
switch {
|
|
||||||
case c.IsSet("config-dir"):
|
|
||||||
globalConfigDir = c.String("config-dir")
|
|
||||||
case c.GlobalIsSet("config-dir"):
|
|
||||||
globalConfigDir = c.GlobalString("config-dir")
|
|
||||||
}
|
|
||||||
if globalConfigDir == "" {
|
|
||||||
fatalIf(errors.New("Config directory is empty"), "Unable to get config file.")
|
|
||||||
}
|
|
||||||
// Set global quiet flag.
|
|
||||||
globalQuiet = c.Bool("quiet") || c.GlobalBool("quiet")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for updates and print a notification message
|
|
||||||
func checkUpdate() {
|
|
||||||
// Do not print update messages, if quiet flag is set.
|
|
||||||
if !globalQuiet {
|
|
||||||
updateMsg, _, err := getReleaseUpdate(minioUpdateStableURL, 1*time.Second)
|
|
||||||
if err != nil {
|
|
||||||
// Ignore any errors during getReleaseUpdate(), possibly
|
|
||||||
// because of network errors.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if updateMsg.Update {
|
|
||||||
console.Println(updateMsg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generic Minio initialization to create/load config, prepare loggers, etc..
|
|
||||||
func minioInit() {
|
|
||||||
// Sets new config directory.
|
|
||||||
setGlobalConfigPath(globalConfigDir)
|
|
||||||
|
|
||||||
// Migrate any old version of config / state files to newer format.
|
|
||||||
migrate()
|
|
||||||
|
|
||||||
// Initialize config.
|
|
||||||
configCreated, err := initConfig()
|
|
||||||
fatalIf(err, "Unable to initialize minio config.")
|
|
||||||
if configCreated {
|
|
||||||
console.Println("Created minio configuration file at " + mustGetConfigPath())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch access keys from environment variables and update the config.
|
|
||||||
accessKey := os.Getenv("MINIO_ACCESS_KEY")
|
|
||||||
secretKey := os.Getenv("MINIO_SECRET_KEY")
|
|
||||||
if accessKey != "" && secretKey != "" {
|
|
||||||
// Set new credentials.
|
|
||||||
serverConfig.SetCredential(credential{
|
|
||||||
AccessKeyID: accessKey,
|
|
||||||
SecretAccessKey: secretKey,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if !isValidAccessKey(serverConfig.GetCredential().AccessKeyID) {
|
|
||||||
fatalIf(errInvalidArgument, "Invalid access key. Accept only a string starting with a alphabetic and containing from 5 to 20 characters.")
|
|
||||||
}
|
|
||||||
if !isValidSecretKey(serverConfig.GetCredential().SecretAccessKey) {
|
|
||||||
fatalIf(errInvalidArgument, "Invalid secret key. Accept only a string containing from 8 to 40 characters.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable all loggers by now.
|
|
||||||
enableLoggers()
|
|
||||||
|
|
||||||
// Init the error tracing module.
|
|
||||||
initError()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main main for minio server.
|
// Main main for minio server.
|
||||||
func Main() {
|
func Main() {
|
||||||
app := registerApp()
|
app := registerApp()
|
||||||
app.Before = func(c *cli.Context) error {
|
app.Before = func(c *cli.Context) error {
|
||||||
|
configDir := c.GlobalString("config-dir")
|
||||||
|
if configDir == "" {
|
||||||
|
fatalIf(errors.New("Config directory is empty"), "Unable to get config file.")
|
||||||
|
}
|
||||||
|
// Sets new config directory.
|
||||||
|
setGlobalConfigPath(configDir)
|
||||||
|
|
||||||
// Valid input arguments to main.
|
// Valid input arguments to main.
|
||||||
checkMainSyntax(c)
|
checkMainSyntax(c)
|
||||||
|
|
||||||
|
// Migrate any old version of config / state files to newer format.
|
||||||
|
migrate()
|
||||||
|
|
||||||
|
// Initialize config.
|
||||||
|
configCreated, err := initConfig()
|
||||||
|
fatalIf(err, "Unable to initialize minio config.")
|
||||||
|
if configCreated {
|
||||||
|
console.Println("Created minio configuration file at " + mustGetConfigPath())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch access keys from environment variables and update the config.
|
||||||
|
accessKey := os.Getenv("MINIO_ACCESS_KEY")
|
||||||
|
secretKey := os.Getenv("MINIO_SECRET_KEY")
|
||||||
|
if accessKey != "" && secretKey != "" {
|
||||||
|
// Set new credentials.
|
||||||
|
serverConfig.SetCredential(credential{
|
||||||
|
AccessKeyID: accessKey,
|
||||||
|
SecretAccessKey: secretKey,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if !isValidAccessKey(serverConfig.GetCredential().AccessKeyID) {
|
||||||
|
fatalIf(errInvalidArgument, "Invalid access key. Accept only a string starting with a alphabetic and containing from 5 to 20 characters.")
|
||||||
|
}
|
||||||
|
if !isValidSecretKey(serverConfig.GetCredential().SecretAccessKey) {
|
||||||
|
fatalIf(errInvalidArgument, "Invalid secret key. Accept only a string containing from 8 to 40 characters.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable all loggers by now.
|
||||||
|
enableLoggers()
|
||||||
|
|
||||||
|
// Init the error tracing module.
|
||||||
|
initError()
|
||||||
|
|
||||||
|
// Set global quiet flag.
|
||||||
|
globalQuiet = c.Bool("quiet") || c.GlobalBool("quiet")
|
||||||
|
|
||||||
|
// Do not print update messages, if quiet flag is set.
|
||||||
|
if !globalQuiet {
|
||||||
|
if c.Args().Get(0) != "update" {
|
||||||
|
updateMsg, _, err := getReleaseUpdate(minioUpdateStableURL, 1*time.Second)
|
||||||
|
if err != nil {
|
||||||
|
// Ignore any errors during getReleaseUpdate(), possibly
|
||||||
|
// because of network errors.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if updateMsg.Update {
|
||||||
|
console.Println(updateMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,13 +363,8 @@ func serverMain(c *cli.Context) {
|
|||||||
cli.ShowCommandHelpAndExit(c, "server", 1)
|
cli.ShowCommandHelpAndExit(c, "server", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set global variables after parsing passed arguments
|
// Set global quiet flag.
|
||||||
setGlobalsFromContext(c)
|
globalQuiet = c.Bool("quiet") || c.GlobalBool("quiet")
|
||||||
|
|
||||||
checkUpdate()
|
|
||||||
|
|
||||||
// Generic initialization
|
|
||||||
minioInit()
|
|
||||||
|
|
||||||
// Server address.
|
// Server address.
|
||||||
serverAddr := c.String("address")
|
serverAddr := c.String("address")
|
||||||
|
@ -265,9 +265,8 @@ func getReleaseUpdate(updateURL string, duration time.Duration) (updateMsg updat
|
|||||||
|
|
||||||
// main entry point for update command.
|
// main entry point for update command.
|
||||||
func mainUpdate(ctx *cli.Context) {
|
func mainUpdate(ctx *cli.Context) {
|
||||||
|
// Set global quiet flag.
|
||||||
setGlobalsFromContext(ctx)
|
if ctx.Bool("quiet") || ctx.GlobalBool("quiet") {
|
||||||
if globalQuiet {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ func mainVersion(ctx *cli.Context) {
|
|||||||
if len(ctx.Args()) != 0 {
|
if len(ctx.Args()) != 0 {
|
||||||
cli.ShowCommandHelpAndExit(ctx, "version", 1)
|
cli.ShowCommandHelpAndExit(ctx, "version", 1)
|
||||||
}
|
}
|
||||||
|
// Set global quiet flag.
|
||||||
setGlobalsFromContext(ctx)
|
if ctx.Bool("quiet") || ctx.GlobalBool("quiet") {
|
||||||
|
return
|
||||||
checkUpdate()
|
}
|
||||||
|
|
||||||
console.Println("Version: " + Version)
|
console.Println("Version: " + Version)
|
||||||
console.Println("Release-Tag: " + ReleaseTag)
|
console.Println("Release-Tag: " + ReleaseTag)
|
||||||
|
Loading…
Reference in New Issue
Block a user