Commit 31e55489 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Add environment suffix to stage & test base path on SFTP server.

parent e16a9621
Pipeline #27859 failed with stages
in 1 minute and 45 seconds
......@@ -4,6 +4,7 @@ metadata:
name: "{{ .Values.deploymentName }}-config"
namespace: memobase
data:
ENVIRONMENT: "{{ .Values.env }}"
APPLICATION_ID: {{ .Values.applicationId }}
SFTP_BASE_PATH: {{ .Values.sftpBasePath }}
EXTENSIONS: {{ .Values.extensions }}
......
......@@ -5,6 +5,7 @@ object Constant {
const val thumbnailFolderName = "thumbnails"
const val sftpBasePathPropertyName = "sftp.basePath"
const val extensionsPropertyName = "extensions"
const val envPropertyName = "env"
const val rdfParserLang = "NTRIPLES"
......
......@@ -24,6 +24,7 @@ import ch.memobase.rdf.RICO
import ch.memobase.reporting.ReportStatus
import ch.memobase.settings.HeaderExtractionTransformSupplier
import ch.memobase.settings.HeaderMetadata
import ch.memobase.settings.InvalidSettingsValue
import ch.memobase.settings.SettingsLoader
import ch.memobase.sftp.SftpClient
import java.io.StringReader
......@@ -47,7 +48,21 @@ class KafkaTopology(private val settings: SettingsLoader) {
private val sftpClient = SftpClient(settings.sftpSettings)
private val previewImageHandler = RemoteResourceHandler(sftpClient)
private val sftpBasePath = appSettings.getProperty(Constant.sftpBasePathPropertyName)
private val sftpBasePath = run {
val env = settings.appSettings.getProperty(Constant.envPropertyName)
val basePath = appSettings.getProperty(Constant.sftpBasePathPropertyName)
when (env) {
"prod" -> {
basePath
}
"stage", "test" -> {
"$basePath/$env"
}
else -> {
throw InvalidSettingsValue("env", env, "prod, stage or test")
}
}
}
private val fileExtensions = appSettings.getProperty(Constant.extensionsPropertyName).split(",")
private val reportingTopic = settings.processReportTopic
......
......@@ -28,7 +28,8 @@ class Service(file: String = "app.yml") {
val settings = SettingsLoader(
listOf(
Constant.sftpBasePathPropertyName,
Constant.extensionsPropertyName
Constant.extensionsPropertyName,
Constant.envPropertyName
),
file,
useStreamsConfig = true,
......
......@@ -4,6 +4,7 @@ sftp:
user: ${SFTP_USER:?system}
password: ${SFTP_PASSWORD:?system}
app:
env: ${ENVIRONMENT:?system}
sftp:
basePath: ${SFTP_BASE_PATH:?system}
extensions: ${EXTENSIONS:?system}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment