diff --git a/project.clj b/project.clj index eb5a10c..2a71112 100644 --- a/project.clj +++ b/project.clj @@ -5,7 +5,7 @@ :url "https://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.10.3"] [org.clojure/tools.reader "1.3.6"] - [org.domaindrivenarchitecture/c4k-common-clj "3.0.1"] + [org.domaindrivenarchitecture/c4k-common-clj "3.0.0"] [hickory "0.7.1"]] :target-path "target/%s/" :source-paths ["src/main/cljc" diff --git a/src/main/cljc/dda/c4k_gitea/gitea.cljc b/src/main/cljc/dda/c4k_gitea/gitea.cljc index fea1169..6da1beb 100644 --- a/src/main/cljc/dda/c4k_gitea/gitea.cljc +++ b/src/main/cljc/dda/c4k_gitea/gitea.cljc @@ -15,21 +15,19 @@ (s/def ::default-app-name string?) (s/def ::fqdn pred/fqdn-string?) (s/def ::mailer-from pred/bash-env-string?) -(s/def ::mailer-host pred/fqdn-string?) -(s/def ::mailer-port pred/port-number?) +(s/def ::mailer-host-port pred/host-and-port-string?) (s/def ::service-domain-whitelist #(pred/string-of-separated-by? pred/fqdn-string? #"," %)) (s/def ::service-noreply-address string?) (s/def ::mailer-user pred/bash-env-string?) (s/def ::mailer-pw pred/bash-env-string?) (s/def ::issuer pred/letsencrypt-issuer?) -(s/def ::volume-total-storage-size (partial pred/int-gt-n? 5)) +(s/def ::volume-total-storage-size int?) ;TODO extend this for checking lower size limits (def config-defaults {:issuer "staging"}) (def config? (s/keys :req-un [::fqdn ::mailer-from - ::mailer-host - ::mailer-port + ::mailer-host-port ::service-noreply-address] :opt-un [::issuer ::default-app-name @@ -49,7 +47,10 @@ (defn data-storage-by-volume-size [total root] - (- total root)) + (cond + (and (<= total 20) (> total 5)) (- total root) + (and (<= total 100) (> total 20)) (- total root) + (> total 100) (- total root))) #?(:cljs @@ -75,8 +76,7 @@ (let [{:keys [default-app-name fqdn mailer-from - mailer-host - mailer-port + mailer-host-port service-domain-whitelist service-noreply-address] :or {default-app-name "Gitea instance" @@ -88,8 +88,7 @@ (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 "MAILER_HOST" mailer-host) - (cm/replace-all-matching-values-by-new-value "MAILER_PORT" (str mailer-port)) + (cm/replace-all-matching-values-by-new-value "HOSTANDPORT" mailer-host-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/cljs/dda/c4k_gitea/browser.cljs b/src/main/cljs/dda/c4k_gitea/browser.cljs index 17f00c5..174d1bb 100644 --- a/src/main/cljs/dda/c4k_gitea/browser.cljs +++ b/src/main/cljs/dda/c4k_gitea/browser.cljs @@ -32,8 +32,7 @@ (cm/concat-vec (br/generate-input-field "fqdn" "Your fqdn:" "repo.test.de") (br/generate-input-field "mailer-from" "Your mailer email address:" "test@test.de") - (br/generate-input-field "mailer-host" "Your mailer host address:" "test.de") - (br/generate-input-field "mailer-port" "Your mailer port number:" "123") + (br/generate-input-field "mailer-host-port" "Your mailer host with port:" "test.de:123") (br/generate-input-field "service-noreply-address" "Your noreply domain:" "test.de") (br/generate-input-field "issuer" "(Optional) Your issuer prod/staging:" "") (br/generate-input-field "app-name" "(Optional) Your app name:" "") @@ -77,8 +76,7 @@ (defn validate-all! [] (br/validate! "fqdn" ::gitea/fqdn) (br/validate! "mailer-from" ::gitea/mailer-from) - (br/validate! "mailer-host" ::gitea/mailer-host) - (br/validate! "mailer-port" ::gitea/mailer-port) + (br/validate! "mailer-host-port" ::gitea/mailer-host-port) (br/validate! "service-noreply-address" ::gitea/service-noreply-address) (br/validate! "issuer" ::gitea/issuer :optional true :deserializer keyword) (br/validate! "app-name" ::gitea/default-app-name) @@ -106,8 +104,7 @@ (br/set-output!))))) (add-validate-listener "fqdn") (add-validate-listener "mailer-from") - (add-validate-listener "mailer-host") - (add-validate-listener "mailer-port") + (add-validate-listener "mailer-host-port") (add-validate-listener "service-noreply-address") (add-validate-listener "app-name") (add-validate-listener "domain-whitelist") diff --git a/src/main/resources/gitea/appini-env-configmap.yaml b/src/main/resources/gitea/appini-env-configmap.yaml index 8ccec77..000a63e 100644 --- a/src/main/resources/gitea/appini-env-configmap.yaml +++ b/src/main/resources/gitea/appini-env-configmap.yaml @@ -38,9 +38,8 @@ data: GITEA__mailer__ENABLED: "true" GITEA__mailer__FROM: FROM GITEA__mailer__MAILER_TYPE: smtp+startls - GITEA__mailer__SMTP_ADDR: MAILER_HOST - GITEA__mailer__SMTP_PORT: MAILER_PORT - + # TODO: jem 2022-08-02: outdated, use SMTP_ADDR & SMTP_PORT instead + GITEA__mailer__HOST: HOSTANDPORT #[oauth2] GITEA__oauth2__ENABLE: "true" diff --git a/src/test/cljc/dda/c4k_gitea/gitea_test.cljc b/src/test/cljc/dda/c4k_gitea/gitea_test.cljc index 6c7d81a..556a186 100644 --- a/src/test/cljc/dda/c4k_gitea/gitea_test.cljc +++ b/src/test/cljc/dda/c4k_gitea/gitea_test.cljc @@ -16,10 +16,8 @@ :APP_NAME-c2 "test gitea", :GITEA__mailer__FROM-c1 "", :GITEA__mailer__FROM-c2 "test@test.com", - :GITEA__mailer__SMTP_ADDR-c1 "m.t.de", - :GITEA__mailer__SMTP_PORT-c1 "123", - :GITEA__mailer__SMTP_ADDR-c2 "mail.test.com", - :GITEA__mailer__SMTP_PORT-c2 "456", + :GITEA__mailer__HOST-c1 "m.t.de:123", + :GITEA__mailer__HOST-c2 "mail.test.com:123", :GITEA__server__DOMAIN-c1 "test.de", :GITEA__server__DOMAIN-c2 "test.com", :GITEA__server__ROOT_URL-c1 "https://test.de", @@ -33,16 +31,14 @@ (th/map-diff (cut/generate-appini-env {:default-app-name "" :fqdn "test.de" :mailer-from "" - :mailer-host "m.t.de" - :mailer-port 123 + :mailer-host-port "m.t.de:123" :service-domain-whitelist "adb.de" :service-noreply-address "" }) (cut/generate-appini-env {:default-app-name "test gitea" :fqdn "test.com" :mailer-from "test@test.com" - :mailer-host "mail.test.com" - :mailer-port 456 + :mailer-host-port "mail.test.com:123" :service-domain-whitelist "test.com,test.net" :service-noreply-address "noreply@test.com" }))))) diff --git a/valid-config.edn b/valid-config.edn index 4584117..cf37f4d 100644 --- a/valid-config.edn +++ b/valid-config.edn @@ -3,8 +3,7 @@ :fqdn "test.de" :issuer "staging" :mailer-from "test@test.de" -:mailer-host "test.de" -:mailer-port 123 +:mailer-host-port "test.de:123" :service-whitelist-domains "test.de" :service-noreply-address "noreply@test.de" :volume-total-storage-size 6