diff options
author | Remigiusz Janeczek <remigiusz.janeczek@nokia.com> | 2021-07-29 09:48:08 +0200 |
---|---|---|
committer | Remigiusz Janeczek <remigiusz.janeczek@nokia.com> | 2021-07-29 10:42:22 +0200 |
commit | 87881ed77a6554ff4e1fccc55c1f5602fe03cc12 (patch) | |
tree | 521053440d1fb79b49053cb460648c6ffbbdb639 /rest-services/cbs-client/src/main | |
parent | 66dabe6f627183eeaa9be7491c3743549fa7ff39 (diff) |
Make CbsClient config and policy paths configurable
Issue-ID: DCAEGEN2-2692
Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com>
Change-Id: Ia9a7f265233fc78ac083180aea30d68407b6d487
Diffstat (limited to 'rest-services/cbs-client/src/main')
2 files changed, 21 insertions, 0 deletions
diff --git a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java index 00dbf8a0..e43cf312 100644 --- a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java +++ b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java @@ -28,6 +28,8 @@ import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl.CbsClientRes import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl.CbsLookup; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsClientConfiguration; import org.onap.dcaegen2.services.sdk.security.ssl.TrustStoreKeys; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import reactor.core.publisher.Mono; /** @@ -38,6 +40,8 @@ import reactor.core.publisher.Mono; * @since 1.1.2 */ public class CbsClientFactory { + private static final Logger LOGGER = LoggerFactory.getLogger(CbsClientFactory.class); + /** * <p>Creates Mono which will emit instance of {@link CbsClient} when service discovery is complete.</p> * @@ -55,6 +59,7 @@ public class CbsClientFactory { * @since 1.1.2 */ public static @NotNull Mono<CbsClient> createCbsClient(CbsClientConfiguration configuration) { + LOGGER.info("Configuration used for CBS Client: {}", configuration); return Mono.fromCallable(() -> buildHttpClient(configuration.trustStoreKeys())) .cache() .flatMap(httpClient -> createCbsClientMono(httpClient, configuration)); diff --git a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/model/CbsClientConfiguration.java b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/model/CbsClientConfiguration.java index 41848855..6eec6674 100644 --- a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/model/CbsClientConfiguration.java +++ b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/model/CbsClientConfiguration.java @@ -72,6 +72,15 @@ public interface CbsClientConfiguration { */ String ENV_APP_NAME = "HOSTNAME"; + /** + * Name of environment variable containing path to application config file. + */ + String ENV_CBS_CLIENT_CONFIG_PATH = "CBS_CLIENT_CONFIG_PATH"; + + /** + * Name of environment variable containing path to policies file. + */ + String ENV_CBS_CLIENT_POLICY_PATH = "CBS_CLIENT_POLICY_PATH"; /** * Name of environment variable containing Consul host name. @@ -148,6 +157,13 @@ public interface CbsClientConfiguration { ImmutableCbsClientConfiguration.Builder configBuilder = ImmutableCbsClientConfiguration.builder() .hostname(getEnv(ENV_CBS_HOSTNAME)) .appName(getEnv(ENV_APP_NAME)); + + Optional.ofNullable(System.getenv(ENV_CBS_CLIENT_CONFIG_PATH)) + .ifPresent(configBuilder::configMapFilePath); + + Optional.ofNullable(System.getenv(ENV_CBS_CLIENT_POLICY_PATH)) + .ifPresent(configBuilder::policySyncFilePath); + return Optional.ofNullable(pathToCaCert).filter(certPath -> !"".equals(certPath)) .map(certPath -> createSslHttpConfig(configBuilder, certPath)) .orElseGet(() -> createPlainHttpConfig(configBuilder)); |