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
|
||||
(:require [orchestra.core :refer [defn-spec]]
|
||||
[clojure.spec.test.alpha :as st]
|
||||
[cheshire.core :refer [generate-string]]
|
||||
[dda.build.devops :as d]
|
||||
[dda.build.provs.domain :as domain]
|
||||
[dda.build.terragrunt.domain :as td]
|
||||
[dda.build.infrastructure :as i]))
|
||||
(:require [clojure.spec.alpha :as s]
|
||||
[orchestra.core :refer [defn-spec]]
|
||||
[clojure.spec.test.alpha :as st]
|
||||
[cheshire.core :refer [generate-string]]
|
||||
[dda.build.c4k :as c4k]
|
||||
[dda.build.terragrunt :as tg]
|
||||
[dda.build.provs.domain :as domain]
|
||||
[dda.build.infrastructure :as i]))
|
||||
|
||||
(def default
|
||||
(merge d/default {:k3s-output-filename "out_k3sServerConfig.yaml"
|
||||
:k3s-provision-user "root"
|
||||
:c4k-output-filename "c4k-app.yaml"
|
||||
:email "default@email.rep"
|
||||
:echo false}))
|
||||
(merge c4k/default
|
||||
{:k3s-output-filename "out_k3sServerConfig.yaml"
|
||||
:k3s-provision-user "root"
|
||||
: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?
|
||||
[devops ::d/devops
|
||||
tf-out ::td/tf-out]
|
||||
[devops ::provs
|
||||
tf-out ::tg/tf-out]
|
||||
(let [config (merge default devops)]
|
||||
(doseq [c (domain/provs-server-command config tf-out)]
|
||||
(i/execute! c config))))
|
||||
|
@ -28,8 +32,8 @@
|
|||
Default: out_k3sServerConfig.yaml
|
||||
can be changed by adding another value for ':k3s-output-filename'
|
||||
"
|
||||
[devops ::d/devops
|
||||
tf-out ::td/tf-out]
|
||||
[devops ::provs
|
||||
tf-out ::tg/tf-out]
|
||||
(let [config (merge default devops)
|
||||
tf-out-k3s-config (domain/create-k3s-config config tf-out)]
|
||||
(->> tf-out-k3s-config
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
(s/def ::k3s-output-filename string?)
|
||||
(s/def ::k3s-provision-user pred/bash-env-string?)
|
||||
(s/def ::config
|
||||
(s/keys :req-un [::d/name ::d/stage ::d/project-root-path ::d/build-dir-name ::d/debug
|
||||
::d/dry-run ::c4k-d/c4k-output-filename
|
||||
::email ::echo ::k3s-output-filename ::k3s-provision-user]
|
||||
:opt-un [::d/module]))
|
||||
(s/merge ::c4k-d/config
|
||||
(s/keys :req-un [::email ::echo ::k3s-output-filename ::k3s-provision-user ::fqdn ::ipv4 ::ipv6])))
|
||||
(s/def ::node
|
||||
(s/keys :req-un [::ipv4 ::ipv6]))
|
||||
(s/def ::letsencryptEndpoint pred/letsencrypt-issuer?)
|
||||
|
|
|
@ -8,37 +8,8 @@
|
|||
(st/instrument `cut/provs-server-command)
|
||||
(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
|
||||
(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"
|
||||
:project-root-path "../.."
|
||||
:build-dir-name "target"
|
||||
|
@ -48,10 +19,13 @@
|
|||
:dry-run false
|
||||
:k3s-output-filename "k3s-out.yaml"
|
||||
:k3s-provision-user "root"
|
||||
:c4k-config-filename "config.yaml"
|
||||
:c4k-auth-filename "auth.yaml"
|
||||
:c4k-output-filename "out.yaml"
|
||||
:c4k-config-input "config.yaml"
|
||||
:c4k-auth-input"auth.yaml"
|
||||
:c4k-output "out.yaml"
|
||||
: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 "::"}}}))))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue