Implement boolean-from-string

This commit is contained in:
erik 2023-06-07 12:55:54 +02:00
parent 746d1da685
commit fe97bbea29

View file

@ -20,11 +20,17 @@
(st/blank? input) (st/blank? input)
(pred/string-of-separated-by? pred/fqdn-string? #"," input))) (pred/string-of-separated-by? pred/fqdn-string? #"," input)))
(defn boolean-from-string [input]
(cond
(= input "true") true
(= input "false") false
:else nil))
(defn boolean-string? (defn boolean-string?
[input] [input]
(and (and
(string? input) (string? input)
(boolean? (Boolean/valueOf input)))) (boolean? (boolean-from-string input))))
(s/def ::default-app-name string?) (s/def ::default-app-name string?)
(s/def ::fqdn pred/fqdn-string?) (s/def ::fqdn pred/fqdn-string?)
@ -85,7 +91,7 @@
service-noreply-address] service-noreply-address]
:or {default-app-name "forgejo instance" :or {default-app-name "forgejo instance"
service-domain-whitelist fqdn}} config service-domain-whitelist fqdn}} config
deploy-federated-bool (boolean (Boolean/valueOf deploy-federated))] deploy-federated-bool (boolean-from-string deploy-federated)]
(-> (->
(yaml/load-as-edn "forgejo/appini-env-configmap.yaml") (yaml/load-as-edn "forgejo/appini-env-configmap.yaml")
(cm/replace-all-matching-values-by-new-value "APPNAME" default-app-name) (cm/replace-all-matching-values-by-new-value "APPNAME" default-app-name)
@ -135,7 +141,7 @@
(defn-spec generate-deployment pred/map-or-seq? (defn-spec generate-deployment pred/map-or-seq?
[config config?] [config config?]
(let [{:keys [deploy-federated]} config (let [{:keys [deploy-federated]} config
deploy-federated-bool (boolean (Boolean/valueOf deploy-federated))] deploy-federated-bool (boolean-from-string deploy-federated)]
(-> (->
(yaml/load-as-edn "forgejo/deployment.yaml") (yaml/load-as-edn "forgejo/deployment.yaml")
(cm/replace-all-matching-values-by-new-value "IMAGE_NAME" (cm/replace-all-matching-values-by-new-value "IMAGE_NAME"