From 79157ea4570ecb0fb7763516a7912e4295a768fa Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 28 Apr 2023 11:57:18 +0200 Subject: [PATCH] Split mailer host into addr and port This became possible in version 1.18. We are currently using 1.19 --- src/main/cljc/dda/c4k_forgejo/core.cljc | 3 ++- src/main/cljc/dda/c4k_forgejo/forgejo.cljc | 12 ++++++++---- src/main/resources/forgejo/appini-env-configmap.yaml | 4 ++-- src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc | 12 ++++++++---- src/test/resources/forgejo-test/valid-config.yaml | 3 ++- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/main/cljc/dda/c4k_forgejo/core.cljc b/src/main/cljc/dda/c4k_forgejo/core.cljc index 5485dce..d63b477 100644 --- a/src/main/cljc/dda/c4k_forgejo/core.cljc +++ b/src/main/cljc/dda/c4k_forgejo/core.cljc @@ -12,7 +12,8 @@ (def config? (s/keys :req-un [::forgejo/fqdn ::forgejo/mailer-from - ::forgejo/mailer-host-port + ::forgejo/mailer-host + ::forgejo/mailer-port ::forgejo/service-noreply-address] :opt-un [::forgejo/issuer ::forgejo/default-app-name diff --git a/src/main/cljc/dda/c4k_forgejo/forgejo.cljc b/src/main/cljc/dda/c4k_forgejo/forgejo.cljc index 9891825..5367550 100644 --- a/src/main/cljc/dda/c4k_forgejo/forgejo.cljc +++ b/src/main/cljc/dda/c4k_forgejo/forgejo.cljc @@ -23,7 +23,8 @@ (s/def ::default-app-name string?) (s/def ::fqdn pred/fqdn-string?) (s/def ::mailer-from pred/bash-env-string?) -(s/def ::mailer-host-port pred/host-and-port-string?) +(s/def ::mailer-host pred/bash-env-string?) +(s/def ::mailer-port pred/bash-env-string?) (s/def ::service-domain-whitelist domain-list?) (s/def ::service-noreply-address string?) (s/def ::mailer-user pred/bash-env-string?) @@ -35,7 +36,8 @@ (def config? (s/keys :req-un [::fqdn ::mailer-from - ::mailer-host-port + ::mailer-host + ::mailer-port ::service-noreply-address] :opt-un [::issuer ::default-app-name @@ -66,7 +68,8 @@ (let [{:keys [default-app-name fqdn mailer-from - mailer-host-port + mailer-host + mailer-port service-domain-whitelist service-noreply-address] :or {default-app-name "forgejo instance" @@ -78,7 +81,8 @@ (cm/replace-all-matching-values-by-new-value "FQDN" fqdn) (cm/replace-all-matching-values-by-new-value "URL" (str "https://" fqdn)) (cm/replace-all-matching-values-by-new-value "FROM" mailer-from) - (cm/replace-all-matching-values-by-new-value "HOSTANDPORT" mailer-host-port) + (cm/replace-all-matching-values-by-new-value "MAILERHOST" mailer-host) + (cm/replace-all-matching-values-by-new-value "MAILERPORT" mailer-port) (cm/replace-all-matching-values-by-new-value "WHITELISTDOMAINS" service-domain-whitelist) (cm/replace-all-matching-values-by-new-value "NOREPLY" service-noreply-address)))) diff --git a/src/main/resources/forgejo/appini-env-configmap.yaml b/src/main/resources/forgejo/appini-env-configmap.yaml index c2e1090..632d02a 100644 --- a/src/main/resources/forgejo/appini-env-configmap.yaml +++ b/src/main/resources/forgejo/appini-env-configmap.yaml @@ -38,8 +38,8 @@ data: FORGEJO__mailer__ENABLED: "true" FORGEJO__mailer__FROM: FROM FORGEJO__mailer__MAILER_TYPE: smtp+startls - # TODO: jem 2022-08-02: outdated with v1.18, use SMTP_ADDR & SMTP_PORT instead - FORGEJO__mailer__HOST: HOSTANDPORT + FORGEJO__mailer__SMTP_ADDR: MAILERHOST + FORGEJO__mailer__SMTP_PORT: MAILERPORT #[oauth2] FORGEJO__oauth2__ENABLE: "true" diff --git a/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc b/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc index f3b4516..ef03fa6 100644 --- a/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc +++ b/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc @@ -16,8 +16,10 @@ :APP_NAME-c2 "test forgejo", :FORGEJO__mailer__FROM-c1 "", :FORGEJO__mailer__FROM-c2 "test@test.com", - :FORGEJO__mailer__HOST-c1 "m.t.de:123", - :FORGEJO__mailer__HOST-c2 "mail.test.com:123", + :FORGEJO__mailer__SMTP_ADDR-c1 "m.t.de", + :FORGEJO__mailer__SMTP_ADDR-c2 "mail.test.com", + :FORGEJO__mailer__SMTP_PORT-c1 "123", + :FORGEJO__mailer__SMTP_PORT-c2 "456", :FORGEJO__server__DOMAIN-c1 "test.de", :FORGEJO__server__DOMAIN-c2 "test.com", :FORGEJO__server__ROOT_URL-c1 "https://test.de", @@ -31,14 +33,16 @@ (th/map-diff (cut/generate-appini-env {:default-app-name "" :fqdn "test.de" :mailer-from "" - :mailer-host-port "m.t.de:123" + :mailer-host "m.t.de" + :mailer-port "123" :service-domain-whitelist "adb.de" :service-noreply-address "" }) (cut/generate-appini-env {:default-app-name "test forgejo" :fqdn "test.com" :mailer-from "test@test.com" - :mailer-host-port "mail.test.com:123" + :mailer-host "mail.test.com" + :mailer-port "456" :service-domain-whitelist "test.com,test.net" :service-noreply-address "noreply@test.com" }))))) diff --git a/src/test/resources/forgejo-test/valid-config.yaml b/src/test/resources/forgejo-test/valid-config.yaml index 4fe83b2..1badecb 100644 --- a/src/test/resources/forgejo-test/valid-config.yaml +++ b/src/test/resources/forgejo-test/valid-config.yaml @@ -2,7 +2,8 @@ default-app-name: "Meissas awesome forgejo" fqdn: "test.de" issuer: "staging" mailer-from: "test@test.de" -mailer-host-port: "test.de:123" +mailer-host: "test.de" +mailer-port: "123" service-whitelist-domains: "test.de" service-noreply-address: "noreply@test.de" volume-total-storage-size: 6