diff --git a/CHANGELOG.md b/CHANGELOG.md index b2f5b6d8..1849ed0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [6.4.2] - 2021-01-03 + +### Fixed + +- N3DR does not fail if parameter is empty and not populated in + `~/.n3dr/config.yml` reported by + [der-eismann](https://github.com/der-eismann). + ## [6.4.1] - 2021-01-03 ### Changed @@ -604,7 +612,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Download all artifacts from a certain Nexus3 repository. -[Unreleased]: https://github.com/030/n3dr/compare/6.4.1...HEAD +[Unreleased]: https://github.com/030/n3dr/compare/6.4.2...HEAD +[6.4.2]: https://github.com/030/n3dr/compare/6.4.1...6.4.2 [6.4.1]: https://github.com/030/n3dr/compare/6.4.0...6.4.1 [6.4.0]: https://github.com/030/n3dr/compare/6.3.0...6.4.0 [6.3.0]: https://github.com/030/n3dr/compare/6.2.0...6.3.0 diff --git a/README.md b/README.md index fa365ab7..7d525a64 100644 --- a/README.md +++ b/README.md @@ -314,7 +314,7 @@ n3dr config \ ### Build ```bash -docker build -t utrecht/n3dr:6.4.1 . +docker build -t utrecht/n3dr:6.4.2 . ``` [![dockeri.co](https://dockeri.co/image/utrecht/n3dr)](https://hub.docker.com/r/utrecht/n3dr) @@ -324,7 +324,7 @@ docker build -t utrecht/n3dr:6.4.1 . ```bash docker run -it \ -v /home/${USER}/.n3dr:/root/.n3dr \ - -v /tmp/n3dr:/tmp/n3dr utrecht/n3dr:6.4.1 + -v /tmp/n3dr:/tmp/n3dr utrecht/n3dr:6.4.2 ``` ### Upload @@ -333,7 +333,7 @@ docker run -it \ docker run -it \ --entrypoint=/bin/ash \ -v /home/${USER}/.n3dr:/root/.n3dr \ - -v /tmp/n3dr:/tmp/n3dr utrecht/n3dr:6.4.1 + -v /tmp/n3dr:/tmp/n3dr utrecht/n3dr:6.4.2 ``` navigate to the repository folder, e.g. `/tmp/n3dr/download*/` and upload: diff --git a/build/package/snap/snapcraft.yaml b/build/package/snap/snapcraft.yaml index ae370667..73374753 100644 --- a/build/package/snap/snapcraft.yaml +++ b/build/package/snap/snapcraft.yaml @@ -1,7 +1,7 @@ --- name: n3dr base: core20 -version: 6.4.1 +version: 6.4.2 summary: Nexus3 Disaster Recovery description: | Download all artifacts at once or migrate automatically from Nexus to Nexus. diff --git a/cmd/n3dr/root.go b/cmd/n3dr/root.go index eb6fc963..353e144c 100644 --- a/cmd/n3dr/root.go +++ b/cmd/n3dr/root.go @@ -116,22 +116,39 @@ func initConfig() { viper.AutomaticEnv() } +func valueInConfigFile(key string) (string, error) { + conf := viper.ConfigFileUsed() + log.Infof("%s parameter empty. Reading it from config file: '%s'", key, conf) + value := viper.GetString(key) + if value == "" { + return "", fmt.Errorf("key: '%s' does not seem to contain a value. Check whether this key is populated in the config file: '%s'", key, conf) + } + return value, nil +} + func parseVarsFromConfig() { + var err error if !anonymous { if n3drUser == "" { - log.Infof("n3drUser empty. Reading if from '%v'", viper.ConfigFileUsed()) - n3drUser = viper.GetString("n3drUser") + n3drUser, err = valueInConfigFile("n3drUser") + if err != nil { + log.Fatal(err) + } } if n3drPass == "" { - log.Infof("n3drPass empty. Reading if from '%v'", viper.ConfigFileUsed()) - n3drPass = viper.GetString("n3drPass") + n3drPass, err = valueInConfigFile("n3drPass") + if err != nil { + log.Fatal(err) + } } } if n3drURL == "" { - log.Infof("n3drURL empty. Reading if from '%v'", viper.ConfigFileUsed()) - n3drURL = viper.GetString("n3drURL") + n3drURL, err = valueInConfigFile("n3drURL") + if err != nil { + log.Fatal(err) + } } }