From e688b54db7667e9a7a1cd8a0daa682e631c36368 Mon Sep 17 00:00:00 2001 From: Jakub Dudycz Date: Tue, 31 Jul 2018 14:49:35 +0200 Subject: Remove default consul configuration Default consul configuration is not needed in real life use case and it doesnt even bring anything useful in our test environment, since it's immediately overriden. Tasks: - remove default consul configuration - make "config-url" argument required Closes ONAP-727 Change-Id: I4a01cebfc6b2918fa3aa6020504def60572b09da Signed-off-by: Jakub Dudycz Issue-ID: DCAEGEN2-601 --- .../collectors/veshv/main/ArgVesHvConfiguration.kt | 39 +++++++++++++--------- .../veshv/main/ArgVesHvConfigurationTest.kt | 32 ++++++++++++------ 2 files changed, 46 insertions(+), 25 deletions(-) (limited to 'hv-collector-main/src') diff --git a/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfiguration.kt b/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfiguration.kt index 77d074e5..7c958b97 100644 --- a/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfiguration.kt +++ b/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfiguration.kt @@ -30,7 +30,16 @@ import org.onap.dcae.collectors.veshv.domain.SecurityConfiguration import org.onap.dcae.collectors.veshv.model.ConfigurationProviderParams import org.onap.dcae.collectors.veshv.model.ServerConfiguration import org.onap.dcae.collectors.veshv.utils.commandline.ArgBasedConfiguration -import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.* +import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.CERT_FILE +import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.CONSUL_CONFIG_URL +import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.CONSUL_FIRST_REQUEST_DELAY +import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.CONSUL_REQUEST_INTERVAL +import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.DUMMY_MODE +import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.IDLE_TIMEOUT_SEC +import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.LISTEN_PORT +import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.PRIVATE_KEY_FILE +import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.SSL_DISABLE +import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.TRUST_CERT_FILE import java.time.Duration internal class ArgVesHvConfiguration : ArgBasedConfiguration(DefaultParser()) { @@ -54,8 +63,7 @@ internal class ArgVesHvConfiguration : ArgBasedConfiguration = + ForOption extensions { + binding { + val configUrl = cmdLine.stringValue(CONSUL_CONFIG_URL).bind() + val firstRequestDelay = cmdLine.longValue(CONSUL_FIRST_REQUEST_DELAY, DefaultValues.CONSUL_FIRST_REQUEST_DELAY) + val requestInterval = cmdLine.longValue(CONSUL_REQUEST_INTERVAL, DefaultValues.CONSUL_REQUEST_INTERVAL) - private fun createConfigurationProviderParams(cmdLine: CommandLine): ConfigurationProviderParams { - val configUrl = cmdLine.stringValue(CONSUL_CONFIG_URL, DefaultValues.CONFIG_URL) - val firstRequestDelay = cmdLine.longValue(CONSUL_FIRST_REQUEST_DELAY, DefaultValues.CONSUL_FIRST_REQUEST_DELAY) - val requestInterval = cmdLine.longValue(CONSUL_REQUEST_INTERVAL, DefaultValues.CONSUL_REQUEST_INTERVAL) - - return ConfigurationProviderParams( - configUrl, - Duration.ofSeconds(firstRequestDelay), - Duration.ofSeconds(requestInterval) - ) - } + ConfigurationProviderParams( + configUrl, + Duration.ofSeconds(firstRequestDelay), + Duration.ofSeconds(requestInterval) + ) + }.fix() + } private fun createSecurityConfiguration(cmdLine: CommandLine): SecurityConfiguration { val sslDisable = cmdLine.hasOption(SSL_DISABLE) @@ -95,7 +105,6 @@ internal class ArgVesHvConfiguration : ArgBasedConfiguration