[#532] cli: Respect XDG base directory spec
All checks were successful
DCO action / DCO (pull_request) Successful in 2m55s
Vulncheck / Vulncheck (pull_request) Successful in 3m43s
Tests and linters / Lint (pull_request) Successful in 5m23s
Tests and linters / Tests with -race (pull_request) Successful in 5m34s
Pre-commit hooks / Pre-commit (pull_request) Successful in 6m6s
Tests and linters / Run gofumpt (pull_request) Successful in 6m10s
Build / Build Components (pull_request) Successful in 6m34s
Tests and linters / gopls check (pull_request) Successful in 8m4s
Tests and linters / Staticcheck (pull_request) Successful in 8m36s
Tests and linters / Tests (pull_request) Successful in 10m30s
All checks were successful
DCO action / DCO (pull_request) Successful in 2m55s
Vulncheck / Vulncheck (pull_request) Successful in 3m43s
Tests and linters / Lint (pull_request) Successful in 5m23s
Tests and linters / Tests with -race (pull_request) Successful in 5m34s
Pre-commit hooks / Pre-commit (pull_request) Successful in 6m6s
Tests and linters / Run gofumpt (pull_request) Successful in 6m10s
Build / Build Components (pull_request) Successful in 6m34s
Tests and linters / gopls check (pull_request) Successful in 8m4s
Tests and linters / Staticcheck (pull_request) Successful in 8m36s
Tests and linters / Tests (pull_request) Successful in 10m30s
XDG base directory specification defines where various files should be looked by an application. Hopefully, this makes `frostfs-cli` more predictable and pleasant to work with. Luckily for us, golang already has everything we need in the stdlib. This commit also gets rid of `github.com/mitchellh/go-homedir` dependency. Close #532 Refs #1455 Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
6c45a17af6
commit
7e1f5b25d1
3 changed files with 3 additions and 5 deletions
|
@ -21,7 +21,6 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/misc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/config"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/gendoc"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
@ -113,12 +112,12 @@ func initConfig() {
|
|||
viper.SetConfigFile(cfgFile)
|
||||
} else {
|
||||
// Find home directory.
|
||||
home, err := homedir.Dir()
|
||||
configDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
common.PrintVerbose(rootCmd, "Get homedir: %s", err)
|
||||
common.PrintVerbose(rootCmd, "Get config dir: %s", err)
|
||||
} else {
|
||||
// Search config in `$HOME/.config/frostfs-cli/` with name "config.yaml"
|
||||
viper.AddConfigPath(filepath.Join(home, ".config", "frostfs-cli"))
|
||||
viper.AddConfigPath(filepath.Join(configDir, "frostfs-cli"))
|
||||
viper.SetConfigName("config")
|
||||
viper.SetConfigType("yaml")
|
||||
}
|
||||
|
|
1
go.mod
1
go.mod
|
@ -27,7 +27,6 @@ require (
|
|||
github.com/hashicorp/golang-lru/v2 v2.0.7
|
||||
github.com/klauspost/compress v1.17.4
|
||||
github.com/mailru/easyjson v0.7.7
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/mr-tron/base58 v1.2.0
|
||||
github.com/multiformats/go-multiaddr v0.12.1
|
||||
github.com/nspcc-dev/neo-go v0.106.3
|
||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
Loading…
Reference in a new issue