| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2018-03-01 12:13:33 +08:00
										 |  |  |  * Minio Cloud Storage, (C) 2017, 2018 Minio, Inc. | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *     http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  * limitations under the License. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package cmd | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  | 	"context" | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 	"errors" | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  | 	"net" | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 	"os" | 
					
						
							|  |  |  | 	"path/filepath" | 
					
						
							| 
									
										
										
										
											2018-03-30 05:38:26 +08:00
										 |  |  | 	"strconv" | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 	"strings" | 
					
						
							|  |  |  | 	"time" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 02:05:56 +08:00
										 |  |  | 	etcd "github.com/coreos/etcd/client" | 
					
						
							| 
									
										
										
										
											2018-05-12 03:02:30 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 	"github.com/minio/cli" | 
					
						
							| 
									
										
										
										
											2018-04-06 06:04:40 +08:00
										 |  |  | 	"github.com/minio/minio/cmd/logger" | 
					
						
							| 
									
										
										
										
											2017-11-01 02:54:32 +08:00
										 |  |  | 	"github.com/minio/minio/pkg/auth" | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  | 	"github.com/minio/minio/pkg/dns" | 
					
						
							| 
									
										
										
										
											2018-05-12 03:02:30 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/minio/minio-go/pkg/set" | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Check for updates and print a notification message
 | 
					
						
							|  |  |  | func checkUpdate(mode string) { | 
					
						
							| 
									
										
										
										
											2017-12-16 04:33:42 +08:00
										 |  |  | 	// Its OK to ignore any errors during doUpdate() here.
 | 
					
						
							|  |  |  | 	if updateMsg, _, currentReleaseTime, latestReleaseTime, err := getUpdateInfo(2*time.Second, mode); err == nil { | 
					
						
							|  |  |  | 		if globalInplaceUpdateDisabled { | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  | 			logger.StartupMessage(updateMsg) | 
					
						
							| 
									
										
										
										
											2017-12-16 04:33:42 +08:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  | 			logger.StartupMessage(prepareUpdateMessage("Run `minio update`", latestReleaseTime.Sub(currentReleaseTime))) | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  | // Initialize and load config from remote etcd or local config directory
 | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | func initConfig() { | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  | 	if globalEtcdClient != nil { | 
					
						
							| 
									
										
										
										
											2018-04-24 02:05:56 +08:00
										 |  |  | 		kapi := etcd.NewKeysAPI(globalEtcdClient) | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  | 		ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) | 
					
						
							|  |  |  | 		_, err := kapi.Get(ctx, getConfigFile(), nil) | 
					
						
							|  |  |  | 		cancel() | 
					
						
							|  |  |  | 		if err == nil { | 
					
						
							|  |  |  | 			logger.FatalIf(migrateConfig(), "Config migration failed.") | 
					
						
							|  |  |  | 			logger.FatalIf(loadConfig(), "Unable to load config version: '%s'.", serverConfigVersion) | 
					
						
							|  |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2018-04-24 02:05:56 +08:00
										 |  |  | 			if etcd.IsKeyNotFound(err) { | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  | 				logger.FatalIf(newConfig(), "Unable to initialize minio config for the first time.") | 
					
						
							| 
									
										
										
										
											2018-05-12 03:02:30 +08:00
										 |  |  | 				logger.Info("Created minio configuration file successfully at %v", globalEtcdClient.Endpoints()) | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				logger.FatalIf(err, "Unable to load config version: '%s'.", serverConfigVersion) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 	if isFile(getConfigFile()) { | 
					
						
							| 
									
										
										
										
											2018-05-10 06:11:24 +08:00
										 |  |  | 		logger.FatalIf(migrateConfig(), "Config migration failed") | 
					
						
							| 
									
										
										
										
											2018-05-09 10:04:36 +08:00
										 |  |  | 		logger.FatalIf(loadConfig(), "Unable to load the configuration file") | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  | 		// Config file does not exist, we create it fresh and return upon success.
 | 
					
						
							| 
									
										
										
										
											2018-05-10 06:11:24 +08:00
										 |  |  | 		logger.FatalIf(newConfig(), "Unable to initialize minio config for the first time") | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  | 		logger.Info("Created minio configuration file successfully at " + getConfigDir()) | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func handleCommonCmdArgs(ctx *cli.Context) { | 
					
						
							| 
									
										
										
										
											2018-03-01 12:13:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	var configDir string | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if ctx.IsSet("config-dir") { | 
					
						
							|  |  |  | 		configDir = ctx.String("config-dir") | 
					
						
							|  |  |  | 	} else if ctx.GlobalIsSet("config-dir") { | 
					
						
							|  |  |  | 		configDir = ctx.GlobalString("config-dir") | 
					
						
							|  |  |  | 		// cli package does not expose parent's "config-dir" option.  Below code is workaround.
 | 
					
						
							|  |  |  | 		if configDir == "" || configDir == getConfigDir() { | 
					
						
							|  |  |  | 			if ctx.Parent().GlobalIsSet("config-dir") { | 
					
						
							|  |  |  | 				configDir = ctx.Parent().GlobalString("config-dir") | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-03-01 12:13:33 +08:00
										 |  |  | 	} else { | 
					
						
							|  |  |  | 		// Neither local nor global config-dir option is provided.  In this case, try to use
 | 
					
						
							|  |  |  | 		// default config directory.
 | 
					
						
							|  |  |  | 		configDir = getConfigDir() | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 		if configDir == "" { | 
					
						
							| 
									
										
										
										
											2018-05-10 06:11:24 +08:00
										 |  |  | 			logger.FatalIf(errors.New("missing option"), "config-dir option must be provided") | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-03-01 12:13:33 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-01 12:13:33 +08:00
										 |  |  | 	if configDir == "" { | 
					
						
							| 
									
										
										
										
											2018-05-10 06:11:24 +08:00
										 |  |  | 		logger.FatalIf(errors.New("empty directory"), "Configuration directory cannot be empty") | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-01 12:13:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Disallow relative paths, figure out absolute paths.
 | 
					
						
							|  |  |  | 	configDirAbs, err := filepath.Abs(configDir) | 
					
						
							| 
									
										
										
										
											2018-04-06 06:04:40 +08:00
										 |  |  | 	logger.FatalIf(err, "Unable to fetch absolute path for config directory %s", configDir) | 
					
						
							| 
									
										
										
										
											2018-03-01 12:13:33 +08:00
										 |  |  | 	setConfigDir(configDirAbs) | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func handleCommonEnvVars() { | 
					
						
							|  |  |  | 	// Start profiler if env is set.
 | 
					
						
							|  |  |  | 	if profiler := os.Getenv("_MINIO_PROFILER"); profiler != "" { | 
					
						
							|  |  |  | 		globalProfiler = startProfiler(profiler) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	accessKey := os.Getenv("MINIO_ACCESS_KEY") | 
					
						
							|  |  |  | 	secretKey := os.Getenv("MINIO_SECRET_KEY") | 
					
						
							|  |  |  | 	if accessKey != "" && secretKey != "" { | 
					
						
							| 
									
										
										
										
											2017-11-01 02:54:32 +08:00
										 |  |  | 		cred, err := auth.CreateCredentials(accessKey, secretKey) | 
					
						
							| 
									
										
										
										
											2018-05-09 10:04:36 +08:00
										 |  |  | 		if err != nil { | 
					
						
							|  |  |  | 			logger.Fatal(uiErrInvalidCredentials(err), "Unable to validate credentials inherited from the shell environment") | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// credential Envs are set globally.
 | 
					
						
							|  |  |  | 		globalIsEnvCreds = true | 
					
						
							|  |  |  | 		globalActiveCred = cred | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if browser := os.Getenv("MINIO_BROWSER"); browser != "" { | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  | 		browserFlag, err := ParseBoolFlag(browser) | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 		if err != nil { | 
					
						
							| 
									
										
										
										
											2018-05-09 10:04:36 +08:00
										 |  |  | 			logger.Fatal(uiErrInvalidBrowserValue(nil).Msg("Unknown value `%s`", browser), "Unable to validate MINIO_BROWSER environment variable") | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// browser Envs are set globally, this does not represent
 | 
					
						
							|  |  |  | 		// if browser is turned off or on.
 | 
					
						
							|  |  |  | 		globalIsEnvBrowser = true | 
					
						
							|  |  |  | 		globalIsBrowserEnabled = bool(browserFlag) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-25 10:04:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-06 03:24:31 +08:00
										 |  |  | 	traceFile := os.Getenv("MINIO_HTTP_TRACE") | 
					
						
							|  |  |  | 	if traceFile != "" { | 
					
						
							|  |  |  | 		var err error | 
					
						
							|  |  |  | 		globalHTTPTraceFile, err = os.OpenFile(traceFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0660) | 
					
						
							| 
									
										
										
										
											2018-04-06 06:04:40 +08:00
										 |  |  | 		logger.FatalIf(err, "error opening file %s", traceFile) | 
					
						
							| 
									
										
										
										
											2018-01-06 03:24:31 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  | 	etcdEndpointsEnv, ok := os.LookupEnv("MINIO_ETCD_ENDPOINTS") | 
					
						
							|  |  |  | 	if ok { | 
					
						
							|  |  |  | 		etcdEndpoints := strings.Split(etcdEndpointsEnv, ",") | 
					
						
							|  |  |  | 		var err error | 
					
						
							| 
									
										
										
										
											2018-04-24 02:05:56 +08:00
										 |  |  | 		globalEtcdClient, err = etcd.New(etcd.Config{ | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  | 			Endpoints: etcdEndpoints, | 
					
						
							| 
									
										
										
										
											2018-05-16 09:20:22 +08:00
										 |  |  | 			Transport: NewCustomHTTPTransport(), | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 		logger.FatalIf(err, "Unable to initialize etcd with %s", etcdEndpoints) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-16 09:20:22 +08:00
										 |  |  | 	globalDomainName, globalIsEnvDomainName = os.LookupEnv("MINIO_DOMAIN") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-12 03:02:30 +08:00
										 |  |  | 	minioEndpointsEnv, ok := os.LookupEnv("MINIO_PUBLIC_IPS") | 
					
						
							|  |  |  | 	if ok { | 
					
						
							|  |  |  | 		minioEndpoints := strings.Split(minioEndpointsEnv, ",") | 
					
						
							|  |  |  | 		globalDomainIPs = set.NewStringSet() | 
					
						
							|  |  |  | 		for i, ip := range minioEndpoints { | 
					
						
							|  |  |  | 			if net.ParseIP(ip) == nil { | 
					
						
							|  |  |  | 				logger.FatalIf(errInvalidArgument, "Unable to initialize Minio server with invalid MINIO_PUBLIC_IPS[%d]: %s", i, ip) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			globalDomainIPs.Add(ip) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if globalDomainName != "" && !globalDomainIPs.IsEmpty() && globalEtcdClient != nil { | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  | 		var err error | 
					
						
							| 
									
										
										
										
											2018-05-12 03:02:30 +08:00
										 |  |  | 		globalDNSConfig, err = dns.NewCoreDNS(globalDomainName, globalDomainIPs, globalMinioPort, globalEtcdClient) | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  | 		logger.FatalIf(err, "Unable to initialize DNS config for %s.", globalDomainName) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | 	if drives := os.Getenv("MINIO_CACHE_DRIVES"); drives != "" { | 
					
						
							| 
									
										
										
										
											2018-03-30 05:38:26 +08:00
										 |  |  | 		driveList, err := parseCacheDrives(strings.Split(drives, cacheEnvDelimiter)) | 
					
						
							| 
									
										
										
										
											2018-05-09 10:04:36 +08:00
										 |  |  | 		if err != nil { | 
					
						
							|  |  |  | 			logger.Fatal(err, "Unable to parse MINIO_CACHE_DRIVES value (%s)", drives) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | 		globalCacheDrives = driveList | 
					
						
							|  |  |  | 		globalIsDiskCacheEnabled = true | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-09 10:04:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | 	if excludes := os.Getenv("MINIO_CACHE_EXCLUDE"); excludes != "" { | 
					
						
							| 
									
										
										
										
											2018-03-30 05:38:26 +08:00
										 |  |  | 		excludeList, err := parseCacheExcludes(strings.Split(excludes, cacheEnvDelimiter)) | 
					
						
							| 
									
										
										
										
											2018-05-09 10:04:36 +08:00
										 |  |  | 		if err != nil { | 
					
						
							| 
									
										
										
										
											2018-05-10 06:11:24 +08:00
										 |  |  | 			logger.Fatal(err, "Unable to parse MINIO_CACHE_EXCLUDE value (`%s`)", excludes) | 
					
						
							| 
									
										
										
										
											2018-05-09 10:04:36 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | 		globalCacheExcludes = excludeList | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-09 10:04:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | 	if expiryStr := os.Getenv("MINIO_CACHE_EXPIRY"); expiryStr != "" { | 
					
						
							| 
									
										
										
										
											2018-03-30 05:38:26 +08:00
										 |  |  | 		expiry, err := strconv.Atoi(expiryStr) | 
					
						
							| 
									
										
										
										
											2018-05-09 10:04:36 +08:00
										 |  |  | 		if err != nil { | 
					
						
							|  |  |  | 			logger.Fatal(uiErrInvalidCacheExpiryValue(err), "Unable to parse MINIO_CACHE_EXPIRY value (`%s`)", expiryStr) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | 		globalCacheExpiry = expiry | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-30 05:38:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  | 	if maxUseStr := os.Getenv("MINIO_CACHE_MAXUSE"); maxUseStr != "" { | 
					
						
							|  |  |  | 		maxUse, err := strconv.Atoi(maxUseStr) | 
					
						
							|  |  |  | 		if err != nil { | 
					
						
							|  |  |  | 			logger.Fatal(uiErrInvalidCacheMaxUse(err), "Unable to parse MINIO_CACHE_MAXUSE value (`%s`)", maxUseStr) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		// maxUse should be a valid percentage.
 | 
					
						
							|  |  |  | 		if maxUse > 0 && maxUse <= 100 { | 
					
						
							|  |  |  | 			globalCacheMaxUse = maxUse | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-16 04:33:42 +08:00
										 |  |  | 	// In place update is true by default if the MINIO_UPDATE is not set
 | 
					
						
							|  |  |  | 	// or is not set to 'off', if MINIO_UPDATE is set to 'off' then
 | 
					
						
							|  |  |  | 	// in-place update is off.
 | 
					
						
							|  |  |  | 	globalInplaceUpdateDisabled = strings.EqualFold(os.Getenv("MINIO_UPDATE"), "off") | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Validate and store the storage class env variables only for XL/Dist XL setups
 | 
					
						
							|  |  |  | 	if globalIsXL { | 
					
						
							|  |  |  | 		var err error | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Check for environment variables and parse into storageClass struct
 | 
					
						
							| 
									
										
										
										
											2017-12-27 12:36:16 +08:00
										 |  |  | 		if ssc := os.Getenv(standardStorageClassEnv); ssc != "" { | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  | 			globalStandardStorageClass, err = parseStorageClass(ssc) | 
					
						
							| 
									
										
										
										
											2018-05-10 06:11:24 +08:00
										 |  |  | 			logger.FatalIf(err, "Invalid value set in environment variable %s", standardStorageClassEnv) | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-27 12:36:16 +08:00
										 |  |  | 		if rrsc := os.Getenv(reducedRedundancyStorageClassEnv); rrsc != "" { | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  | 			globalRRStorageClass, err = parseStorageClass(rrsc) | 
					
						
							| 
									
										
										
										
											2018-05-10 06:11:24 +08:00
										 |  |  | 			logger.FatalIf(err, "Invalid value set in environment variable %s", reducedRedundancyStorageClassEnv) | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Validation is done after parsing both the storage classes. This is needed because we need one
 | 
					
						
							|  |  |  | 		// storage class value to deduce the correct value of the other storage class.
 | 
					
						
							|  |  |  | 		if globalRRStorageClass.Scheme != "" { | 
					
						
							| 
									
										
										
										
											2018-02-01 15:30:07 +08:00
										 |  |  | 			err = validateParity(globalStandardStorageClass.Parity, globalRRStorageClass.Parity) | 
					
						
							| 
									
										
										
										
											2018-05-10 06:11:24 +08:00
										 |  |  | 			logger.FatalIf(err, "Invalid value set in environment variable %s", reducedRedundancyStorageClassEnv) | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  | 			globalIsStorageClass = true | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if globalStandardStorageClass.Scheme != "" { | 
					
						
							| 
									
										
										
										
											2018-02-01 15:30:07 +08:00
										 |  |  | 			err = validateParity(globalStandardStorageClass.Parity, globalRRStorageClass.Parity) | 
					
						
							| 
									
										
										
										
											2018-05-10 06:11:24 +08:00
										 |  |  | 			logger.FatalIf(err, "Invalid value set in environment variable %s", standardStorageClassEnv) | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  | 			globalIsStorageClass = true | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-28 07:44:45 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Get WORM environment variable.
 | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  | 	if worm := os.Getenv("MINIO_WORM"); worm != "" { | 
					
						
							|  |  |  | 		wormFlag, err := ParseBoolFlag(worm) | 
					
						
							|  |  |  | 		if err != nil { | 
					
						
							|  |  |  | 			logger.Fatal(uiErrInvalidWormValue(nil).Msg("Unknown value `%s`", worm), "Unable to validate MINIO_WORM environment variable") | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// worm Envs are set globally, this does not represent
 | 
					
						
							|  |  |  | 		// if worm is turned off or on.
 | 
					
						
							|  |  |  | 		globalIsEnvWORM = true | 
					
						
							|  |  |  | 		globalWORMEnabled = bool(wormFlag) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | } |