diff --git a/README.md b/README.md index d85048b..5953749 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,7 @@ An example of this project environment variables: ``` GHAPP_API_HOST=https://127.0.0.1/github GHAPP_SERVER_PORT=8083 -GHAPP_REDIS_HOST=redis://redis -GHAPP_REDIS_PORT=6380 +GHAPP_REDIS_URL=redis://username:password@host:port WIRE_SDK_API_HOST=https://nginz-https.chala.wire.link WIRE_SDK_API_TOKEN=myApiToken WIRE_SDK_APP_ID=f562e146-dec2-4d85-93c7-7132746b5cca diff --git a/build.gradle.kts b/build.gradle.kts index 82e165e..77bb0b0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -111,8 +111,7 @@ tasks { test { environment("GHAPP_API_HOST", "http://0.0.0.0") environment("GHAPP_SERVER_PORT", "8083") - environment("GHAPP_REDIS_HOST", "redis://localhost") - environment("GHAPP_REDIS_PORT", "6379") + environment("GHAPP_REDIS_URL", "redis://localhost:6379") environment("WIRE_SDK_API_HOST", "https://nginz-https.chala.wire.link") environment("WIRE_SDK_API_TOKEN", "myApiToken") environment("WIRE_SDK_APP_ID", "f562e146-dec2-4d85-93c7-7132746b5cca") diff --git a/docker-compose.yml b/docker-compose.yml index 98ba09b..575d591 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,8 +8,7 @@ services: environment: - GHAPP_API_HOST=${GHAPP_API_HOST} - GHAPP_SERVER_PORT=${GHAPP_SERVER_PORT} - - GHAPP_REDIS_HOST=${GHAPP_REDIS_HOST} - - GHAPP_REDIS_PORT=${GHAPP_REDIS_PORT} + - GHAPP_REDIS_URL=${GHAPP_REDIS_URL} - WIRE_SDK_API_HOST=${WIRE_SDK_API_HOST} - WIRE_SDK_API_TOKEN=${WIRE_SDK_API_TOKEN} - WIRE_SDK_APP_ID=${WIRE_SDK_APP_ID} @@ -28,14 +27,12 @@ services: redis: image: redis:7 container_name: github_redis - environment: - - GHAPP_REDIS_PORT=${GHAPP_REDIS_PORT} restart: unless-stopped ports: - - "${GHAPP_REDIS_PORT}:${GHAPP_REDIS_PORT}" + - "6379:6379" volumes: - redis-data:/data - command: sh -c "redis-server --port $GHAPP_REDIS_PORT --save 60 1 --loglevel warning --appendonly yes" + command: sh -c "redis-server --save 60 1 --loglevel warning --appendonly yes" volumes: redis-data: diff --git a/helm/githubapp/templates/statefulset.yaml b/helm/githubapp/templates/statefulset.yaml index 2a43c98..0304158 100644 --- a/helm/githubapp/templates/statefulset.yaml +++ b/helm/githubapp/templates/statefulset.yaml @@ -68,16 +68,11 @@ spec: key: WIRE_SDK_CRYPTOGRAPHY_STORAGE_PASSWORD {{- end }} {{- if .Values.redis }} - - name: GHAPP_REDIS_HOST + - name: GHAPP_REDIS_URL valueFrom: secretKeyRef: name: {{ .Values.redis.secretName }} - key: {{ .Values.redis.hostKey }} - - name: GHAPP_REDIS_PORT - valueFrom: - secretKeyRef: - name: {{ .Values.redis.secretName }} - key: {{ .Values.redis.portKey }} + key: {{ .Values.redis.urlKey }} {{- end }} volumeMounts: - name: data diff --git a/helm/githubapp/values.yaml b/helm/githubapp/values.yaml index 77e67db..7c5e32b 100644 --- a/helm/githubapp/values.yaml +++ b/helm/githubapp/values.yaml @@ -31,8 +31,7 @@ secrets: redis: secretName: "githubapp-valkey-secrets" - hostKey: "host" - portKey: "port" + urlKey: "url" # Persistent storage configuration persistence: diff --git a/src/main/kotlin/com/wire/github/config/Modules.kt b/src/main/kotlin/com/wire/github/config/Modules.kt index 6d3c13e..ea20554 100644 --- a/src/main/kotlin/com/wire/github/config/Modules.kt +++ b/src/main/kotlin/com/wire/github/config/Modules.kt @@ -5,8 +5,7 @@ import com.wire.github.util.ENV_VAR_API_HOST import com.wire.github.util.ENV_VAR_API_TOKEN import com.wire.github.util.ENV_VAR_APPLICATION_ID import com.wire.github.util.ENV_VAR_CRYPTOGRAPHY_STORAGE_KEY -import com.wire.github.util.ENV_VAR_REDIS_HOST -import com.wire.github.util.ENV_VAR_REDIS_PORT +import com.wire.github.util.ENV_VAR_REDIS_URL import com.wire.github.util.SignatureValidator import com.wire.github.util.TemplateHandler import com.wire.sdk.WireAppSdk @@ -23,7 +22,7 @@ val projectModules = module { } single { SignatureValidator() } single { TemplateHandler() } - single { RedisClient.create("$ENV_VAR_REDIS_HOST:$ENV_VAR_REDIS_PORT") } + single { RedisClient.create(ENV_VAR_REDIS_URL) } single> { get().connect() } } diff --git a/src/main/kotlin/com/wire/github/util/EnvironmentVariables.kt b/src/main/kotlin/com/wire/github/util/EnvironmentVariables.kt index ac924b8..3ae132e 100644 --- a/src/main/kotlin/com/wire/github/util/EnvironmentVariables.kt +++ b/src/main/kotlin/com/wire/github/util/EnvironmentVariables.kt @@ -33,28 +33,15 @@ val ENV_VAR_HOST: String = System ) /** - * Redis Host URL - * In case it needs a password, must be included in this same environment variable. - * Examples: - * - "redis://host" - * - "redis://[:password@]host" + * Redis Connection URL + * Should contain all the necessary information + * Example: rediss://username:password@host:port */ -val ENV_VAR_REDIS_HOST: String = System +val ENV_VAR_REDIS_URL: String = System .getenv() .getOrDefault( - "GHAPP_REDIS_HOST", - "redis://localhost" - ) - -/** - * Redis Port Number - * To used when connecting and also exposed via docker-compose. - */ -val ENV_VAR_REDIS_PORT: String = System - .getenv() - .getOrDefault( - "GHAPP_REDIS_PORT", - "6379" + "GHAPP_REDIS_URL", + "redis://localhost:6379" ) /**