Skip to content

Commit

Permalink
DSND-2697: Consolidate env variables to application properties (#122)
Browse files Browse the repository at this point in the history
* DSND-2697: Consolidate .yml file into application.properties

*delete application.yml file.
*put all env variables into application.properties file.

* DSND-2697: Remove all unnecessary env variables

* unnecessary logger.namespace env replaced with application.namespace
* any unnecessary variables in application.properties or pom removed
  • Loading branch information
crowlandsCH authored Jul 10, 2024
1 parent 043291d commit e39b116
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 51 deletions.
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@
<CHS_API_KEY>key</CHS_API_KEY>
<API_URL>key</API_URL>
<PAYMENTS_API_URL>key</PAYMENTS_API_URL>
<DOCUMENT_API_LOCAL_URL>key</DOCUMENT_API_LOCAL_URL>
</environmentVariables>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
package uk.gov.companieshouse.pscdataapi.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import uk.gov.companieshouse.logging.Logger;
import uk.gov.companieshouse.logging.LoggerFactory;
import uk.gov.companieshouse.pscdataapi.PscDataApiApplication;

/**
* Configuration class for logging.
*/
@Configuration
public class LoggingConfig {

@Value("${logger.namespace}")
private String loggerNamespace;

/**
* Creates a logger with specified namespace.
*
* @return the {@link LoggerFactory} for the specified namespace
*/
@Bean
public Logger logger() {
return LoggerFactory.getLogger(loggerNamespace);
return LoggerFactory.getLogger(PscDataApiApplication.APPLICATION_NAME_SPACE);
}
}
12 changes: 10 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
management.endpoints.web.base-path=/psc-data-api
management.endpoints.web.path-mapping.health=/healthcheck
chs.api.kafka.uri=/private/resource-changed
chs.api.kafka.kind=someKind

chs.api.kafka.url=${CHS_KAFKA_API_URL:localhost}
chs.api.kafka.resource-changed.uri=${PSC_API_RESOURCE_CHANGED_URI:/private/resource-changed}
chs.api.metrics.url=${API_LOCAL_URL:localhost}

spring.data.mongodb.uri=${MONGODB_URL:mongodb://mongo:27017}
spring.data.mongodb.name=company_pscs

spring.data.jackson.default-property-inclusion=NON_NULL

feature.seeding_collection_enabled=${SEEDING_COLLECTION_ENABLED:false}
31 changes: 0 additions & 31 deletions src/main/resources/application.yml

This file was deleted.

12 changes: 6 additions & 6 deletions src/test/resources/application-feature_flag_enabled.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ company-metrics-api.endpoint=localhost

chs.kafka.api.endpoint=http://localhost:8888
chs.kafka.api.key=chsApiKey
chs.api.kafka.url=${CHS_KAFKA_API_URL:localhost}
chs.api.kafka.resource-changed.uri=${PSC_API_RESOURCE_CHANGED_URI:/private/resource-changed}
chs.api.metrics.url=${API_LOCAL_URL:localhost}

api.api-url=${API_URL:localhost}
api.api-key=${CHS_API_KEY:chsApiKey}
Expand All @@ -12,11 +15,8 @@ items-per-page-max-internal=500

management.endpoints.web.base-path=/psc-data-api
management.endpoints.web.path-mapping.health=/healthcheck
chs.api.kafka.url=${CHS_KAFKA_API_URL:localhost}
chs.api.kafka.resource-changed.uri=${PSC_API_RESOURCE_CHANGED_URI:/private/resource-changed}
chs.api.metrics.url=${API_LOCAL_URL:localhost}
logger.namespace=psc-data-api

spring.data.mongodb.uri=${MONGODB_URL:mongodb://mongo:27017}
spring.data.mongodb.name=company_pscs
spring.jackson.default-property-inclusion=NON_NULL
mongodb.pscs.collection.name=delta_company_pscs

spring.jackson.default-property-inclusion=NON_NULL
12 changes: 6 additions & 6 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ company-metrics-api.endpoint=localhost

chs.kafka.api.endpoint=http://localhost:8888
chs.kafka.api.key=chsApiKey
chs.api.kafka.url=${CHS_KAFKA_API_URL:localhost}
chs.api.kafka.resource-changed.uri=${PSC_API_RESOURCE_CHANGED_URI:/private/resource-changed}
chs.api.metrics.url=${API_LOCAL_URL:localhost}

api.api-url=${API_URL:localhost}
api.api-key=${CHS_API_KEY:chsApiKey}
Expand All @@ -12,11 +15,8 @@ items-per-page-max-internal=500

management.endpoints.web.base-path=/psc-data-api
management.endpoints.web.path-mapping.health=/healthcheck
chs.api.kafka.url=${CHS_KAFKA_API_URL:localhost}
chs.api.kafka.resource-changed.uri=${PSC_API_RESOURCE_CHANGED_URI:/private/resource-changed}
chs.api.metrics.url=${API_LOCAL_URL:localhost}
logger.namespace=psc-data-api

spring.data.mongodb.uri=${MONGODB_URL:mongodb://mongo:27017}
spring.data.mongodb.name=company_pscs
spring.jackson.default-property-inclusion=NON_NULL
mongodb.pscs.collection.name=delta_company_pscs

spring.jackson.default-property-inclusion=NON_NULL

0 comments on commit e39b116

Please sign in to comment.