cli: Handle missing home directory #1455

Merged
fyrchik merged 1 commit from fyrchik/frostfs-node:fix-cli-home into master 2024-10-29 14:28:46 +00:00

View file

@ -114,12 +114,14 @@ func initConfig() {
} else {
// Find home directory.
home, err := homedir.Dir()
commonCmd.ExitOnErr(rootCmd, "", err)
// Search config in `$HOME/.config/frostfs-cli/` with name "config.yaml"
viper.AddConfigPath(filepath.Join(home, ".config", "frostfs-cli"))
viper.SetConfigName("config")
viper.SetConfigType("yaml")
if err != nil {
common.PrintVerbose(rootCmd, "Get homedir: %s", err)
} else {
// Search config in `$HOME/.config/frostfs-cli/` with name "config.yaml"
viper.AddConfigPath(filepath.Join(home, ".config", "frostfs-cli"))
viper.SetConfigName("config")
viper.SetConfigType("yaml")
}
}
viper.SetEnvPrefix(envPrefix)