in cmd/mount_all.go [82:187]
func processCommand() error {
configFileExists := true
if options.ConfigFile == "" {
// Config file is not set in cli parameters
// Blobfuse2 defaults to config.yaml in current directory
// If the file does not exists then user might have configured required things in env variables
// Fall back to defaults and let components fail if all required env variables are not set.
_, err := os.Stat(common.DefaultConfigFilePath)
if err != nil && os.IsNotExist(err) {
configFileExists = false
} else {
options.ConfigFile = common.DefaultConfigFilePath
}
}
if configFileExists {
err := parseConfig()
if err != nil {
return err
}
}
err := config.Unmarshal(&options)
if err != nil {
return fmt.Errorf("failed to unmarshal config [%s]", err.Error())
}
if !config.IsSet("logging.file-path") {
options.Logging.LogFilePath = common.DefaultLogFilePath
}
if !config.IsSet("logging.level") {
options.Logging.LogLevel = "LOG_WARNING"
}
err = options.validate(true)
if err != nil {
return err
}
var logLevel common.LogLevel
err = logLevel.Parse(options.Logging.LogLevel)
if err != nil {
return fmt.Errorf("invalid log level [%s]", err.Error())
}
err = log.SetDefaultLogger(options.Logging.Type, common.LogConfig{
FilePath: options.Logging.LogFilePath,
MaxFileSize: options.Logging.MaxLogFileSize,
FileCount: options.Logging.LogFileCount,
Level: logLevel,
TimeTracker: options.Logging.TimeTracker,
})
if err != nil {
return fmt.Errorf("failed to initialize logger [%s]", err.Error())
}
if !disableVersionCheck {
err := VersionCheck()
if err != nil {
log.Err(err.Error())
}
}
config.Set("mount-path", options.MountPath)
// Add this flag in config map so that other components be aware that we are running
// in 'mount all' command mode. This is used by azstorage component for certain config checks
config.SetBool("mount-all-containers", true)
log.Crit("Starting Blobfuse2 Mount All: %s", common.Blobfuse2Version)
log.Crit("Logging level set to : %s", logLevel.String())
// Get allowlist/denylist containers from the config
err = config.UnmarshalKey("mountall", &mountAllOpts)
if err != nil {
log.Warn("mount all: mountall config error (invalid config attributes) [%s]\n", err.Error())
}
// Validate config is to be secured on write or not
if options.PassPhrase == "" {
options.PassPhrase = os.Getenv(SecureConfigEnvName)
}
if options.SecureConfig && options.PassPhrase == "" {
return fmt.Errorf("key not provided to decrypt config file")
}
containerList, err := getContainerList()
if err != nil {
return err
}
if len(containerList) > 0 {
containerList = filterAllowedContainerList(containerList)
err = mountAllContainers(containerList, options.ConfigFile, options.MountPath, configFileExists)
if err != nil {
return err
}
} else {
fmt.Println("No containers to mount from this account")
}
return nil
}