Skip to content

Commit

Permalink
OK-356 Korjattu ympäristökohtaisia konfiguraatioita
Browse files Browse the repository at this point in the history
  • Loading branch information
jkorri committed Jan 15, 2024
1 parent a656ce9 commit 7d4c857
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ object LocalUtil {
// verifioidaan ses-identiteetti ja konfiguroidaan eventit
val sesClient = AwsUtil.sesClient
sesClient.verifyDomainIdentity(VerifyDomainIdentityRequest.builder()
.domain("hahtuvaopintopolku.fi")
.domain("localopintopolku.fi")
.build())
sesClient.createConfigurationSet(CreateConfigurationSetRequest.builder()
.configurationSet(ConfigurationSet.builder()
Expand Down Expand Up @@ -124,6 +124,7 @@ object LocalUtil {
LocalUtil.setupLahetys()
LocalUtil.setupMonitoring()

System.setProperty("ENVIRONMENT_NAME", "local")
System.setProperty("FAKEMAILER_HOST", "localhost")
System.setProperty("FAKEMAILER_PORT", "1025")
System.setProperty("ATTACHMENTS_BUCKET_NAME", LocalUtil.LOCAL_ATTACHMENTS_BUCKET_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class LambdaHandler extends RequestHandler[SQSEvent, Void], Resource {
.to(vastaanottaja.kontakti.nimi.getOrElse(null), vastaanottaja.kontakti.sahkoposti)
.buildEmail())
else
sendTestEmail(vastaanottaja, builder.from(viesti.lahettaja.nimi.getOrElse(null), "noreply@hahtuvaopintopolku.fi"))
sendTestEmail(vastaanottaja, builder.from(viesti.lahettaja.nimi.getOrElse(null), s"noreply@${ConfigurationUtil.opintopolkuDomain}"))
}

LOG.info("Lähetetty viesti: " + vastaanottaja.tunniste)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ import java.util.stream.Collectors

object LambdaHandler {

final val ENVIRONMENT_NAME_KEY = "ENVIRONMENT_NAME"
val opintopolkuDomain = {
val environment = ConfigurationUtil.getConfigurationItem(ENVIRONMENT_NAME_KEY).get
if("pallero".equals(environment))
"testiopintopolku.fi"
else
environment + "opintopolku.fi"
}
val opintopolkuDomain = ConfigurationUtil.opintopolkuDomain

// Cas
System.setProperty("cas-service.service", s"https://viestinvalitys.${opintopolkuDomain}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.{DeserializationFeature, MapperFeature, ObjectMapper, SerializationFeature}
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import fi.oph.viestinvalitys.util.ConfigurationUtil
import io.swagger.v3.oas.models.OpenAPI
import io.swagger.v3.oas.models.servers.Server
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer
Expand All @@ -26,7 +27,7 @@ class VastaanottoConfiguration {
@Bean
@Profile(Array("default")) def customOpenAPI: OpenAPI = {
val server = new Server
server.setUrl("https://viestinvalitys.hahtuvaopintopolku.fi")
server.setUrl(s"https://viestinvalitys.${ConfigurationUtil.opintopolkuDomain}")
new OpenAPI().servers(util.List.of(server))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ object ConfigurationUtil {
final val SKANNAUS_QUEUE_URL_KEY = "SKANNAUS_QUEUE_URL"
final val SESMONITOROINTI_QUEUE_URL_KEY = "SES_MONITOROINTI_QUEUE_URL"

final val ENVIRONMENT_NAME_KEY = "ENVIRONMENT_NAME"

lazy val opintopolkuDomain = {
val environment = ConfigurationUtil.getConfigurationItem(ENVIRONMENT_NAME_KEY).get
if ("pallero".equals(environment))
"testiopintopolku.fi"
else
environment + "opintopolku.fi"
}

def getConfigurationItem(key: String): Option[String] =
sys.env.get(key).orElse(sys.props.get(key))

Expand Down

0 comments on commit 7d4c857

Please sign in to comment.