[#1455] cli: Handle missing home directory
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m36s
DCO action / DCO (pull_request) Successful in 1m47s
Vulncheck / Vulncheck (pull_request) Successful in 2m16s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m30s
Build / Build Components (pull_request) Successful in 2m35s
Tests and linters / gopls check (pull_request) Successful in 2m54s
Tests and linters / Staticcheck (pull_request) Successful in 2m54s
Tests and linters / Lint (pull_request) Successful in 3m44s
Tests and linters / Tests (pull_request) Successful in 4m25s
Tests and linters / Tests with -race (pull_request) Successful in 6m13s
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m36s
DCO action / DCO (pull_request) Successful in 1m47s
Vulncheck / Vulncheck (pull_request) Successful in 2m16s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m30s
Build / Build Components (pull_request) Successful in 2m35s
Tests and linters / gopls check (pull_request) Successful in 2m54s
Tests and linters / Staticcheck (pull_request) Successful in 2m54s
Tests and linters / Lint (pull_request) Successful in 3m44s
Tests and linters / Tests (pull_request) Successful in 4m25s
Tests and linters / Tests with -race (pull_request) Successful in 6m13s
go-homedir library incorrectly handles some of the errors that could occur. It is archived, so no PR, but let's fix it on our side. The scenario in case: executing command in an empty environment. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
81f4cdbb91
commit
433aab12bb
1 changed files with 8 additions and 6 deletions
|
@ -114,12 +114,14 @@ func initConfig() {
|
||||||
} else {
|
} else {
|
||||||
// Find home directory.
|
// Find home directory.
|
||||||
home, err := homedir.Dir()
|
home, err := homedir.Dir()
|
||||||
commonCmd.ExitOnErr(rootCmd, "", err)
|
if err != nil {
|
||||||
|
common.PrintVerbose(rootCmd, "Get homedir: %s", err)
|
||||||
// Search config in `$HOME/.config/frostfs-cli/` with name "config.yaml"
|
} else {
|
||||||
viper.AddConfigPath(filepath.Join(home, ".config", "frostfs-cli"))
|
// Search config in `$HOME/.config/frostfs-cli/` with name "config.yaml"
|
||||||
viper.SetConfigName("config")
|
viper.AddConfigPath(filepath.Join(home, ".config", "frostfs-cli"))
|
||||||
viper.SetConfigType("yaml")
|
viper.SetConfigName("config")
|
||||||
|
viper.SetConfigType("yaml")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.SetEnvPrefix(envPrefix)
|
viper.SetEnvPrefix(envPrefix)
|
||||||
|
|
Loading…
Reference in a new issue