Minor refactorings
This commit is contained in:
parent
1e7b71884d
commit
0a3a85d93d
5 changed files with 26 additions and 22 deletions
|
@ -36,18 +36,18 @@
|
|||
|
||||
(defn-spec generate-http-ingress pred/map-or-seq?
|
||||
[config ingress?]
|
||||
(let [{:keys [http-ingress-name service-name service-port fqdns]} config]
|
||||
(let [{:keys [ingress-name service-name service-port fqdns]} config]
|
||||
(->
|
||||
(yaml/load-as-edn "ingress/http-ingress.yaml")
|
||||
(assoc-in [:metadata :name] http-ingress-name)
|
||||
(assoc-in [:metadata :name] ingress-name)
|
||||
(assoc-in [:spec :rules] (mapv (partial generate-host-rule service-name service-port) fqdns)))))
|
||||
|
||||
(defn-spec generate-https-ingress pred/map-or-seq?
|
||||
[config ingress?]
|
||||
(let [{:keys [https-ingress-name cert-name service-name service-port fqdns]} config]
|
||||
(let [{:keys [ingress-name cert-name service-name service-port fqdns]} config]
|
||||
(->
|
||||
(yaml/load-as-edn "ingress/https-ingress.yaml")
|
||||
(assoc-in [:metadata :name] https-ingress-name)
|
||||
(assoc-in [:metadata :name] ingress-name)
|
||||
(assoc-in [:spec :tls 0 :secretName] cert-name)
|
||||
(assoc-in [:spec :tls 0 :hosts] fqdns)
|
||||
(assoc-in [:spec :rules] (mapv (partial generate-host-rule service-name service-port) fqdns)))))
|
||||
|
|
|
@ -86,9 +86,9 @@
|
|||
#?(:cljs
|
||||
(defmethod yaml/load-resource :website [resource-name]
|
||||
(case resource-name
|
||||
"website/certificate.yaml" (rc/inline "website/certificate.yaml")
|
||||
"website/http-ingress.yaml" (rc/inline "website/http-ingress.yaml")
|
||||
"website/https-ingress.yaml" (rc/inline "website/https-ingress.yaml")
|
||||
"ingress/certificate.yaml" (rc/inline "ingress/certificate.yaml")
|
||||
"ingress/http-ingress.yaml" (rc/inline "ingress/http-ingress.yaml")
|
||||
"ingress/https-ingress.yaml" (rc/inline "ingress/https-ingress.yaml")
|
||||
"website/nginx-configmap.yaml" (rc/inline "website/nginx-configmap.yaml")
|
||||
"website/nginx-deployment.yaml" (rc/inline "website/nginx-deployment.yaml")
|
||||
"website/nginx-service.yaml" (rc/inline "website/nginx-service.yaml")
|
||||
|
@ -102,12 +102,6 @@
|
|||
(defmethod yaml/load-as-edn :website [resource-name]
|
||||
(yaml/from-string (yaml/load-resource resource-name))))
|
||||
|
||||
; generate a list of host-rules from a list of fqdns
|
||||
(defn make-host-rules-from-fqdns
|
||||
[rule fqdns]
|
||||
;function that creates a rule from host names
|
||||
(mapv #(assoc-in rule [:host] %) fqdns))
|
||||
|
||||
(defn-spec generate-website-http-ingress pred/map-or-seq?
|
||||
[config websitedata?]
|
||||
(let [{:keys [unique-name fqdns]} config]
|
||||
|
@ -138,7 +132,7 @@
|
|||
(let [{:keys [unique-name fqdns]} config]
|
||||
(->
|
||||
(yaml/load-as-edn "website/nginx-configmap.yaml")
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn unique-name))
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (replace-dots-by-minus unique-name))
|
||||
(#(assoc-in %
|
||||
[:data :website.conf]
|
||||
(str/replace
|
||||
|
@ -149,21 +143,21 @@
|
|||
(let [{:keys [unique-name]} config]
|
||||
(->
|
||||
(yaml/load-as-edn "website/nginx-deployment.yaml")
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn unique-name)))))
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (replace-dots-by-minus unique-name)))))
|
||||
|
||||
(defn-spec generate-nginx-service pred/map-or-seq?
|
||||
[config websitedata?]
|
||||
(let [{:keys [unique-name]} config]
|
||||
(->
|
||||
(yaml/load-as-edn "website/nginx-service.yaml")
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn unique-name)))))
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (replace-dots-by-minus unique-name)))))
|
||||
|
||||
(defn-spec generate-website-content-volume pred/map-or-seq?
|
||||
[config websitedata?]
|
||||
(let [{:keys [unique-name]} config]
|
||||
(->
|
||||
(yaml/load-as-edn "website/website-content-volume.yaml")
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn unique-name))
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (replace-dots-by-minus unique-name))
|
||||
(cm/replace-all-matching-values-by-new-value "WEBSITESTORAGESIZE" (str (str volume-size) "Gi")))))
|
||||
|
||||
(defn-spec generate-website-build-cron pred/map-or-seq?
|
||||
|
@ -171,14 +165,14 @@
|
|||
(let [{:keys [unique-name]} config]
|
||||
(->
|
||||
(yaml/load-as-edn "website/website-build-cron.yaml")
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn unique-name)))))
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (replace-dots-by-minus unique-name)))))
|
||||
|
||||
(defn-spec generate-website-build-deployment pred/map-or-seq?
|
||||
[config websitedata?]
|
||||
(let [{:keys [unique-name]} config]
|
||||
(->
|
||||
(yaml/load-as-edn "website/website-build-deployment.yaml")
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn unique-name)))))
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (replace-dots-by-minus unique-name)))))
|
||||
|
||||
(defn-spec generate-website-build-secret pred/map-or-seq?
|
||||
[auth websiteauth?]
|
||||
|
@ -190,7 +184,7 @@
|
|||
branchname]} auth]
|
||||
(->
|
||||
(yaml/load-as-edn "website/website-build-secret.yaml")
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn unique-name))
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (replace-dots-by-minus unique-name))
|
||||
(cm/replace-all-matching-values-by-new-value "TOKEN" (b64/encode authtoken))
|
||||
(cm/replace-all-matching-values-by-new-value "URL" (b64/encode
|
||||
(make-gitrepourl
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
(generate-group
|
||||
"credentials"
|
||||
(br/generate-text-area
|
||||
"auth" "Your authentication data for each website/ git repo:"
|
||||
"auth" "Your authentication data for each website or git repo:"
|
||||
"{:auth
|
||||
[{:unique-name \"test.io\",
|
||||
:username \"someuser\",
|
||||
|
|
10
src/main/resources/ingress/host-rule.yaml
Normal file
10
src/main/resources/ingress/host-rule.yaml
Normal file
|
@ -0,0 +1,10 @@
|
|||
host: FQDN
|
||||
http:
|
||||
paths:
|
||||
- pathType: Prefix
|
||||
path: "/"
|
||||
backend:
|
||||
service:
|
||||
name: SERVICE_NAME
|
||||
port:
|
||||
number: SERVICE_PORT
|
|
@ -1,6 +1,6 @@
|
|||
{:issuer "staging"
|
||||
:websites
|
||||
[{:unique-name "test.io" ; todo: call this unique-name
|
||||
[{:unique-name "test.io"
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"]
|
||||
:gitea-host "gitlab.de"
|
||||
:gitea-repo "repo"
|
||||
|
|
Loading…
Reference in a new issue