Merge branch 'yaml-config-reader' into 'master'
Configuration files can now be of type EDN and YAML. See merge request domaindrivenarchitecture/c4k-nextcloud!4
This commit is contained in:
commit
0d3a4c334a
10 changed files with 36 additions and 21 deletions
|
@ -2,7 +2,7 @@
|
||||||
"name": "c4k-nextcloud",
|
"name": "c4k-nextcloud",
|
||||||
"description": "Generate c4k yaml for a nextcloud deployment.",
|
"description": "Generate c4k yaml for a nextcloud deployment.",
|
||||||
"author": "meissa GmbH",
|
"author": "meissa GmbH",
|
||||||
"version": "3.4.2-SNAPSHOT",
|
"version": "4.0.0-SNAPSHOT",
|
||||||
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud#readme",
|
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud#readme",
|
||||||
"repository": "https://www.npmjs.com/package/c4k-nextcloud",
|
"repository": "https://www.npmjs.com/package/c4k-nextcloud",
|
||||||
"license": "APACHE2",
|
"license": "APACHE2",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
(defproject org.domaindrivenarchitecture/c4k-nextcloud "3.4.2-SNAPSHOT"
|
(defproject org.domaindrivenarchitecture/c4k-nextcloud "4.0.0-SNAPSHOT"
|
||||||
:description "nextcloud c4k-installation package"
|
:description "nextcloud c4k-installation package"
|
||||||
:url "https://domaindrivenarchitecture.org"
|
:url "https://domaindrivenarchitecture.org"
|
||||||
:license {:name "Apache License, Version 2.0"
|
:license {:name "Apache License, Version 2.0"
|
||||||
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
|
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
|
||||||
:dependencies [[org.clojure/clojure "1.10.3"]
|
:dependencies [[org.clojure/clojure "1.10.3"]
|
||||||
[org.clojure/tools.reader "1.3.6"]
|
[org.clojure/tools.reader "1.3.6"]
|
||||||
[org.domaindrivenarchitecture/c4k-common-clj "1.1.0"]]
|
[org.domaindrivenarchitecture/c4k-common-clj "2.0.0"]]
|
||||||
:target-path "target/%s/"
|
:target-path "target/%s/"
|
||||||
:source-paths ["src/main/cljc"
|
:source-paths ["src/main/cljc"
|
||||||
"src/main/clj"]
|
"src/main/clj"]
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
[clojure.string :as cs]
|
[clojure.string :as cs]
|
||||||
[clojure.tools.reader.edn :as edn]
|
[clojure.tools.reader.edn :as edn]
|
||||||
[expound.alpha :as expound]
|
[expound.alpha :as expound]
|
||||||
|
[dda.c4k-common.yaml :as yaml]
|
||||||
[dda.c4k-nextcloud.core :as core]
|
[dda.c4k-nextcloud.core :as core]
|
||||||
[dda.c4k-nextcloud.nextcloud :as nextcloud]))
|
[dda.c4k-nextcloud.nextcloud :as nextcloud]))
|
||||||
|
|
||||||
|
@ -42,16 +43,18 @@
|
||||||
:default
|
:default
|
||||||
(let [config-str (slurp config)
|
(let [config-str (slurp config)
|
||||||
auth-str (slurp auth)
|
auth-str (slurp auth)
|
||||||
config-edn (edn/read-string config-str)
|
config-parse-fn (if (yaml/is-yaml? config) yaml/from-string edn/read-string)
|
||||||
auth-edn (edn/read-string auth-str)
|
auth-parse-fn (if (yaml/is-yaml? auth) yaml/from-string edn/read-string)
|
||||||
config-valid? (s/valid? nextcloud/config? config-edn)
|
parsed-config (config-parse-fn config-str)
|
||||||
auth-valid? (s/valid? core/auth? auth-edn)]
|
parsed-auth (auth-parse-fn auth-str)
|
||||||
|
config-valid? (s/valid? nextcloud/config? parsed-config)
|
||||||
|
auth-valid? (s/valid? core/auth? parsed-auth)]
|
||||||
(if (and config-valid? auth-valid?)
|
(if (and config-valid? auth-valid?)
|
||||||
(println (core/generate config-edn auth-edn))
|
(println (core/generate parsed-config parsed-auth))
|
||||||
(do
|
(do
|
||||||
(when (not config-valid?)
|
(when (not config-valid?)
|
||||||
(println
|
(println
|
||||||
(expound/expound-str nextcloud/config? config-edn {:print-specs? false})))
|
(expound/expound-str nextcloud/config? parsed-config {:print-specs? false})))
|
||||||
(when (not auth-valid?)
|
(when (not auth-valid?)
|
||||||
(println
|
(println
|
||||||
(expound/expound-str core/auth? auth-edn {:print-specs? false})))))))))))
|
(expound/expound-str core/auth? parsed-auth {:print-specs? false})))))))))))
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
[dda.c4k-nextcloud.nextcloud :as nextcloud]
|
[dda.c4k-nextcloud.nextcloud :as nextcloud]
|
||||||
[dda.c4k-nextcloud.backup :as backup]))
|
[dda.c4k-nextcloud.backup :as backup]))
|
||||||
|
|
||||||
(def config-defaults {:issuer :staging})
|
(def config-defaults {:issuer "staging"})
|
||||||
|
|
||||||
(def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password
|
(def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password
|
||||||
::nextcloud/nextcloud-admin-user ::nextcloud/nextcloud-admin-password
|
::nextcloud/nextcloud-admin-user ::nextcloud/nextcloud-admin-password
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
(defn generate-certificate [config]
|
(defn generate-certificate [config]
|
||||||
(let [{:keys [fqdn issuer]} config
|
(let [{:keys [fqdn issuer]} config
|
||||||
letsencrypt-issuer (name issuer)]
|
letsencrypt-issuer issuer]
|
||||||
(->
|
(->
|
||||||
(yaml/from-string (yaml/load-resource "nextcloud/certificate.yaml"))
|
(yaml/from-string (yaml/load-resource "nextcloud/certificate.yaml"))
|
||||||
(assoc-in [:spec :commonName] fqdn)
|
(assoc-in [:spec :commonName] fqdn)
|
||||||
|
@ -52,8 +52,8 @@
|
||||||
|
|
||||||
(defn generate-ingress [config]
|
(defn generate-ingress [config]
|
||||||
(let [{:keys [fqdn issuer]
|
(let [{:keys [fqdn issuer]
|
||||||
:or {issuer :staging}} config
|
:or {issuer "staging"}} config
|
||||||
letsencrypt-issuer (name issuer)]
|
letsencrypt-issuer issuer]
|
||||||
(->
|
(->
|
||||||
(yaml/from-string (yaml/load-resource "nextcloud/ingress.yaml"))
|
(yaml/from-string (yaml/load-resource "nextcloud/ingress.yaml"))
|
||||||
(assoc-in [:metadata :annotations :cert-manager.io/cluster-issuer] letsencrypt-issuer)
|
(assoc-in [:metadata :annotations :cert-manager.io/cluster-issuer] letsencrypt-issuer)
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
:postgres-db-password "nextcloud-db-password"
|
:postgres-db-password "nextcloud-db-password"
|
||||||
:nextcloud-admin-user "cloudadmin"
|
:nextcloud-admin-user "cloudadmin"
|
||||||
:nextcloud-admin-password "cloudpassword"
|
:nextcloud-admin-password "cloudpassword"
|
||||||
:issuer :prod
|
:issuer "prod"
|
||||||
:nextcloud-data-volume-path "/var/nextcloud"
|
:nextcloud-data-volume-path "/var/nextcloud"
|
||||||
:postgres-data-volume-path "/var/postgres"
|
:postgres-data-volume-path "/var/postgres"
|
||||||
:aws-access-key-id "aws-id"
|
:aws-access-key-id "aws-id"
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
:postgres-db-password "nextcloud-db-password"
|
:postgres-db-password "nextcloud-db-password"
|
||||||
:nextcloud-admin-user "cloudadmin"
|
:nextcloud-admin-user "cloudadmin"
|
||||||
:nextcloud-admin-password "cloudpassword"
|
:nextcloud-admin-password "cloudpassword"
|
||||||
:issuer :prod
|
:issuer "prod"
|
||||||
:aws-access-key-id "aws-id"
|
:aws-access-key-id "aws-id"
|
||||||
:aws-secret-access-key "aws-secret"
|
:aws-secret-access-key "aws-secret"
|
||||||
:restic-password "restic-pw"
|
:restic-password "restic-pw"
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
:postgres-db-password "nextcloud-db-password"
|
:postgres-db-password "nextcloud-db-password"
|
||||||
:nextcloud-admin-user "cloudadmin"
|
:nextcloud-admin-user "cloudadmin"
|
||||||
:nextcloud-admin-password "cloudpassword"
|
:nextcloud-admin-password "cloudpassword"
|
||||||
:issuer :prod
|
:issuer "prod"
|
||||||
:aws-access-key-id "aws-id"
|
:aws-access-key-id "aws-id"
|
||||||
:aws-secret-access-key "aws-secret"
|
:aws-secret-access-key "aws-secret"
|
||||||
:restic-password "restic-pw"}))))
|
:restic-password "restic-pw"}))))
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
:postgres-db-password "nextcloud-db-password"
|
:postgres-db-password "nextcloud-db-password"
|
||||||
:nextcloud-admin-user "cloudadmin"
|
:nextcloud-admin-user "cloudadmin"
|
||||||
:nextcloud-admin-password "cloudpassword"
|
:nextcloud-admin-password "cloudpassword"
|
||||||
:issuer :prod
|
:issuer "prod"
|
||||||
:aws-access-key-id "aws-id"
|
:aws-access-key-id "aws-id"
|
||||||
:aws-secret-access-key "aws-secret"
|
:aws-secret-access-key "aws-secret"
|
||||||
:restic-password "restic-pw"})
|
:restic-password "restic-pw"})
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
:postgres-db-password "nextcloud-db-password"
|
:postgres-db-password "nextcloud-db-password"
|
||||||
:nextcloud-admin-user "cloudadmin"
|
:nextcloud-admin-user "cloudadmin"
|
||||||
:nextcloud-admin-password "cloudpassword"
|
:nextcloud-admin-password "cloudpassword"
|
||||||
:issuer :prod
|
:issuer "prod"
|
||||||
:aws-access-key-id "aws-id"
|
:aws-access-key-id "aws-id"
|
||||||
:aws-secret-access-key "aws-secret"
|
:aws-secret-access-key "aws-secret"
|
||||||
:restic-password "restic-pw"})
|
:restic-password "restic-pw"})
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
:dnsNames ["xx"]
|
:dnsNames ["xx"]
|
||||||
:issuerRef
|
:issuerRef
|
||||||
{:name "prod", :kind "ClusterIssuer"}}}
|
{:name "prod", :kind "ClusterIssuer"}}}
|
||||||
(cut/generate-certificate {:fqdn "xx" :issuer :prod}))))
|
(cut/generate-certificate {:fqdn "xx" :issuer "prod"}))))
|
||||||
|
|
||||||
(deftest should-generate-ingress
|
(deftest should-generate-ingress
|
||||||
(is (= {:apiVersion "networking.k8s.io/v1"
|
(is (= {:apiVersion "networking.k8s.io/v1"
|
||||||
|
|
7
valid-auth.yaml
Normal file
7
valid-auth.yaml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
postgres-db-user: "nextcloud"
|
||||||
|
postgres-db-password: "nextcloud-db-password"
|
||||||
|
nextcloud-admin-user: "cloudadmin"
|
||||||
|
nextcloud-admin-password: "cloudpassword"
|
||||||
|
aws-access-key-id: "aws-id"
|
||||||
|
aws-secret-access-key: "aws-secret"
|
||||||
|
restic-password: "restic-password"
|
|
@ -1,5 +1,5 @@
|
||||||
{:fqdn "cloud.test.meissa-gmbh.de"
|
{:fqdn "cloud.test.meissa-gmbh.de"
|
||||||
:issuer :staging
|
:issuer "staging"
|
||||||
:nextcloud-data-volume-path "/var/cloud"
|
:nextcloud-data-volume-path "/var/cloud"
|
||||||
:postgres-data-volume-path "/var/postgres"
|
:postgres-data-volume-path "/var/postgres"
|
||||||
:restic-repository "s3:s3.amazonaws.com/your-bucket/your-folder"}
|
:restic-repository "s3:s3.amazonaws.com/your-bucket/your-folder"}
|
5
valid-config.yaml
Normal file
5
valid-config.yaml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
fqdn: "cloud.test.meissa-gmbh.de"
|
||||||
|
issuer: "staging"
|
||||||
|
nextcloud-data-volume-path: "/var/cloud"
|
||||||
|
postgres-data-volume-path: "/var/postgres"
|
||||||
|
restic-repository: "s3:s3.amazonaws.com/your-bucket/your-folder"
|
Loading…
Reference in a new issue