mirror of
https://github.com/minio/minio.git
synced 2025-11-08 21:24:55 -05:00
Simplify running cmd.Main() for external tests (#3636)
An external test that runs cmd.Main() has a difficulty to set cmd arguments
and MINIO_{ACCESS,SECRET}_KEY values, this commit changes a little the current
behavior in a way that helps external tests.
This commit is contained in:
committed by
Harshavardhana
parent
cccf77229d
commit
8e49a3d047
@@ -190,6 +190,8 @@ func minioInit(ctx *cli.Context) {
|
||||
enableLoggers()
|
||||
|
||||
// Fetch access keys from environment variables and update the config.
|
||||
globalEnvAccessKey = os.Getenv("MINIO_ACCESS_KEY")
|
||||
globalEnvSecretKey = os.Getenv("MINIO_SECRET_KEY")
|
||||
if globalEnvAccessKey != "" && globalEnvSecretKey != "" {
|
||||
// Set new credentials.
|
||||
serverConfig.SetCredential(credential{
|
||||
@@ -210,7 +212,7 @@ func minioInit(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
// Main main for minio server.
|
||||
func Main() {
|
||||
func Main(args []string, exitFn func(int)) {
|
||||
app := registerApp()
|
||||
app.Before = func(c *cli.Context) error {
|
||||
// Valid input arguments to main.
|
||||
@@ -224,5 +226,7 @@ func Main() {
|
||||
}
|
||||
|
||||
// Run the app - exit on error.
|
||||
app.RunAndExitOnError()
|
||||
if err := app.Run(args); err != nil {
|
||||
exitFn(1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user