fix spec & test
This commit is contained in:
parent
d2a2ee7572
commit
2932bcf5f8
3 changed files with 30 additions and 54 deletions
|
@ -1,22 +1,26 @@
|
||||||
(ns dda.build.provs
|
(ns dda.build.provs
|
||||||
(:require [orchestra.core :refer [defn-spec]]
|
(:require [clojure.spec.alpha :as s]
|
||||||
[clojure.spec.test.alpha :as st]
|
[orchestra.core :refer [defn-spec]]
|
||||||
[cheshire.core :refer [generate-string]]
|
[clojure.spec.test.alpha :as st]
|
||||||
[dda.build.devops :as d]
|
[cheshire.core :refer [generate-string]]
|
||||||
[dda.build.provs.domain :as domain]
|
[dda.build.c4k :as c4k]
|
||||||
[dda.build.terragrunt.domain :as td]
|
[dda.build.terragrunt :as tg]
|
||||||
[dda.build.infrastructure :as i]))
|
[dda.build.provs.domain :as domain]
|
||||||
|
[dda.build.infrastructure :as i]))
|
||||||
|
|
||||||
(def default
|
(def default
|
||||||
(merge d/default {:k3s-output-filename "out_k3sServerConfig.yaml"
|
(merge c4k/default
|
||||||
:k3s-provision-user "root"
|
{:k3s-output-filename "out_k3sServerConfig.yaml"
|
||||||
:c4k-output-filename "c4k-app.yaml"
|
:k3s-provision-user "root"
|
||||||
:email "default@email.rep"
|
:echo false}))
|
||||||
:echo false}))
|
(s/def ::provs (s/merge ::c4k/c4k
|
||||||
|
(s/keys
|
||||||
|
:req-un [::domain/email ::domain/fqdn ::domain/ipv4 ::domain/ipv6]
|
||||||
|
:opt-un [::domain/echo ::domain/k3s-output-filename ::domain/k3s-provision-user])))
|
||||||
|
|
||||||
(defn-spec run-provs-server! nil?
|
(defn-spec run-provs-server! nil?
|
||||||
[devops ::d/devops
|
[devops ::provs
|
||||||
tf-out ::td/tf-out]
|
tf-out ::tg/tf-out]
|
||||||
(let [config (merge default devops)]
|
(let [config (merge default devops)]
|
||||||
(doseq [c (domain/provs-server-command config tf-out)]
|
(doseq [c (domain/provs-server-command config tf-out)]
|
||||||
(i/execute! c config))))
|
(i/execute! c config))))
|
||||||
|
@ -28,8 +32,8 @@
|
||||||
Default: out_k3sServerConfig.yaml
|
Default: out_k3sServerConfig.yaml
|
||||||
can be changed by adding another value for ':k3s-output-filename'
|
can be changed by adding another value for ':k3s-output-filename'
|
||||||
"
|
"
|
||||||
[devops ::d/devops
|
[devops ::provs
|
||||||
tf-out ::td/tf-out]
|
tf-out ::tg/tf-out]
|
||||||
(let [config (merge default devops)
|
(let [config (merge default devops)
|
||||||
tf-out-k3s-config (domain/create-k3s-config config tf-out)]
|
tf-out-k3s-config (domain/create-k3s-config config tf-out)]
|
||||||
(->> tf-out-k3s-config
|
(->> tf-out-k3s-config
|
||||||
|
|
|
@ -16,10 +16,8 @@
|
||||||
(s/def ::k3s-output-filename string?)
|
(s/def ::k3s-output-filename string?)
|
||||||
(s/def ::k3s-provision-user pred/bash-env-string?)
|
(s/def ::k3s-provision-user pred/bash-env-string?)
|
||||||
(s/def ::config
|
(s/def ::config
|
||||||
(s/keys :req-un [::d/name ::d/stage ::d/project-root-path ::d/build-dir-name ::d/debug
|
(s/merge ::c4k-d/config
|
||||||
::d/dry-run ::c4k-d/c4k-output-filename
|
(s/keys :req-un [::email ::echo ::k3s-output-filename ::k3s-provision-user ::fqdn ::ipv4 ::ipv6])))
|
||||||
::email ::echo ::k3s-output-filename ::k3s-provision-user]
|
|
||||||
:opt-un [::d/module]))
|
|
||||||
(s/def ::node
|
(s/def ::node
|
||||||
(s/keys :req-un [::ipv4 ::ipv6]))
|
(s/keys :req-un [::ipv4 ::ipv6]))
|
||||||
(s/def ::letsencryptEndpoint pred/letsencrypt-issuer?)
|
(s/def ::letsencryptEndpoint pred/letsencrypt-issuer?)
|
||||||
|
|
|
@ -8,37 +8,8 @@
|
||||||
(st/instrument `cut/provs-server-command)
|
(st/instrument `cut/provs-server-command)
|
||||||
(st/instrument `cut/create-k3s-config)
|
(st/instrument `cut/create-k3s-config)
|
||||||
|
|
||||||
(deftest should-calculate-output-path
|
|
||||||
(is (= "../../target/dda-backup/k3s-out.yaml"
|
|
||||||
(cut/output-path {:name "dda-backup"
|
|
||||||
:project-root-path "../.."
|
|
||||||
:build-dir-name "target"
|
|
||||||
:version "4.11.8-dev"
|
|
||||||
:stage "dev"
|
|
||||||
:debug false
|
|
||||||
:dry-run false
|
|
||||||
:c4k-output-filename "out.yaml"
|
|
||||||
:k3s-provision-user "root"
|
|
||||||
:k3s-output-filename "k3s-out.yaml"
|
|
||||||
:email "test@test.t"
|
|
||||||
:echo false})))
|
|
||||||
(is (= "../../target/dda/backup/k3s-out.yaml"
|
|
||||||
(cut/output-path {:name "dda"
|
|
||||||
:module "backup"
|
|
||||||
:project-root-path "../.."
|
|
||||||
:build-dir-name "target"
|
|
||||||
:version "4.11.8-dev"
|
|
||||||
:stage "dev"
|
|
||||||
:debug false
|
|
||||||
:dry-run false
|
|
||||||
:c4k-output-filename "out.yaml"
|
|
||||||
:k3s-provision-user "root"
|
|
||||||
:k3s-output-filename "k3s-out.yaml"
|
|
||||||
:email "test@test.t"
|
|
||||||
:echo false}))))
|
|
||||||
|
|
||||||
(deftest should-calculate-provs-server-command
|
(deftest should-calculate-provs-server-command
|
||||||
(is (= ["provs-server.jar" "k3s" "root@test.test.de" "-c" "../../target/dda-backup/k3s-out.yaml" "-a" "../../target/dda-backup/out.yaml"]
|
(is (= [["provs-server.jar" "k3s" "root@test.test.de" "-c" "../../target/dda-backup/k3s-out.yaml" "-a" "../../target/dda-backup/out.yaml"]]
|
||||||
(cut/provs-server-command {:name "dda-backup"
|
(cut/provs-server-command {:name "dda-backup"
|
||||||
:project-root-path "../.."
|
:project-root-path "../.."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
|
@ -48,10 +19,13 @@
|
||||||
:dry-run false
|
:dry-run false
|
||||||
:k3s-output-filename "k3s-out.yaml"
|
:k3s-output-filename "k3s-out.yaml"
|
||||||
:k3s-provision-user "root"
|
:k3s-provision-user "root"
|
||||||
:c4k-config-filename "config.yaml"
|
:c4k-config-input "config.yaml"
|
||||||
:c4k-auth-filename "auth.yaml"
|
:c4k-auth-input"auth.yaml"
|
||||||
:c4k-output-filename "out.yaml"
|
:c4k-output "out.yaml"
|
||||||
:email "test@test.t"
|
:email "test@test.t"
|
||||||
:echo false}
|
:echo false
|
||||||
|
:fqdn "fq.dn"
|
||||||
|
:ipv4 "1.2.3.4"
|
||||||
|
:ipv6 "2a01:4f8:c012:cb41::1"}
|
||||||
{:out {:sensitive false :type [] :value {:fqdn "test.test.de" :ipv4 "127.0.0.1" :ipv6 "::"}}}))))
|
{:out {:sensitive false :type [] :value {:fqdn "test.test.de" :ipv4 "127.0.0.1" :ipv6 "::"}}}))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue