aboutsummaryrefslogtreecommitdiffstats
path: root/hv-collector-utils
diff options
context:
space:
mode:
authorFilip Krzywka <filip.krzywka@nokia.com>2018-09-17 13:22:41 +0200
committerFilip Krzywka <filip.krzywka@nokia.com>2018-09-17 13:22:41 +0200
commit6bc7018f650ad67301d4d9dbdbc5ae5c05753841 (patch)
treef11ee2676ab1ff16ec9ba74df30a6395ac53b318 /hv-collector-utils
parentba28c3baf96f93558adebaec55cfd4683455e9e9 (diff)
Read flags from env variables
The application configuration should be read from command line options as well as from environment variables. The priority: cmd-line over env over defaults. Change-Id: Ib62d5d68003a006901d9be8a81fca354def8fea4 Issue-ID: DCAEGEN2-748 Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
Diffstat (limited to 'hv-collector-utils')
-rw-r--r--hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/ArgBasedConfiguration.kt3
1 files changed, 2 insertions, 1 deletions
diff --git a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/ArgBasedConfiguration.kt b/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/ArgBasedConfiguration.kt
index da6f2d0a..44d425ea 100644
--- a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/ArgBasedConfiguration.kt
+++ b/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/ArgBasedConfiguration.kt
@@ -74,7 +74,8 @@ abstract class ArgBasedConfiguration<T>(private val parser: CommandLineParser) {
optionValue(cmdLineOpt)
protected fun CommandLine.hasOption(cmdLineOpt: CommandLineOption): Boolean =
- this.hasOption(cmdLineOpt.option.opt)
+ this.hasOption(cmdLineOpt.option.opt) ||
+ System.getenv(cmdLineOpt.environmentVariableName()) != null
protected fun stringPathToPath(path: String): Path = Paths.get(File(path).toURI())