From 006be7f70368ce91986037ae7a032ba00836c6c2 Mon Sep 17 00:00:00 2001 From: Filip Krzywka Date: Tue, 25 Jun 2019 11:32:36 +0200 Subject: Add environment configuration to kafka consumer - HV-VES-specific environment prefix moved inside HvVes modules to allow simpler no-prefix API for other modules - created OptionDSL for brevity Change-Id: I2fabbda1280cc0f913f8a0a04b4a055f39ed1fae Issue-ID: DCAEGEN2-1626 Signed-off-by: Filip Krzywka --- .../dcae/collectors/veshv/config/impl/HvVesCommandLineParser.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sources/hv-collector-configuration') diff --git a/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/impl/HvVesCommandLineParser.kt b/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/impl/HvVesCommandLineParser.kt index c6730a4c..27560642 100644 --- a/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/impl/HvVesCommandLineParser.kt +++ b/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/impl/HvVesCommandLineParser.kt @@ -29,6 +29,7 @@ import org.apache.commons.cli.DefaultParser import org.apache.commons.cli.Options import org.onap.dcae.collectors.veshv.commandline.CommandLineOption.CONFIGURATION_FILE import org.onap.dcae.collectors.veshv.commandline.CommandLineOption.HEALTH_CHECK_API_PORT +import org.onap.dcae.collectors.veshv.commandline.EnvPrefix import org.onap.dcae.collectors.veshv.commandline.WrongArgumentError import org.onap.dcae.collectors.veshv.commandline.intValue import org.onap.dcae.collectors.veshv.commandline.stringValue @@ -42,7 +43,7 @@ internal class HvVesCommandLineParser(private val parser: CommandLineParser = De fun getConfigurationFile(args: Array): Either = parse(args) { - it.stringValue(CONFIGURATION_FILE).map(::File) + it.stringValue(CONFIGURATION_FILE, HV_VES_ENV_PREFIX).map(::File) }.toEither { WrongArgumentError( message = "Base configuration filepath missing on command line", @@ -51,7 +52,7 @@ internal class HvVesCommandLineParser(private val parser: CommandLineParser = De fun getHealthcheckPort(args: Array): Int = parse(args) { - it.intValue(HEALTH_CHECK_API_PORT) + it.intValue(HEALTH_CHECK_API_PORT, HV_VES_ENV_PREFIX) }.getOrElse { logger.info { "Healthcheck port missing on command line, using default: $DEFAULT_HEALTHCHECK_PORT" } DEFAULT_HEALTHCHECK_PORT @@ -76,6 +77,7 @@ internal class HvVesCommandLineParser(private val parser: CommandLineParser = De .let { parser.parse(it, args) } companion object { + private val HV_VES_ENV_PREFIX = EnvPrefix("VESHV") private const val DEFAULT_HEALTHCHECK_PORT: Int = 6060 private val logger = Logger(HvVesCommandLineParser::class) } -- cgit 1.2.3-korg