From 51c654b272ef15ab884c2ffe96975322398b1510 Mon Sep 17 00:00:00 2001 From: bom Date: Mon, 12 Jul 2021 11:16:43 +0200 Subject: [PATCH] make backup optional * backup will not be created if there is no restic-repository in the config --- src/main/cljc/dda/c4k_jira/core.cljc | 11 ++++++----- src/test/cljc/dda/c4k_jira/core_test.cljc | 10 +++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/cljc/dda/c4k_jira/core.cljc b/src/main/cljc/dda/c4k_jira/core.cljc index 85792ad..df9454f 100644 --- a/src/main/cljc/dda/c4k_jira/core.cljc +++ b/src/main/cljc/dda/c4k_jira/core.cljc @@ -11,9 +11,9 @@ (def config-defaults {:issuer :staging}) -(def config? (s/keys :req-un [::jira/fqdn ::restic-repository] +(def config? (s/keys :req-un [::jira/fqdn] :opt-un [::jira/issuer ::jira/jira-data-volume-path - ::postgres/postgres-data-volume-path])) + ::postgres/postgres-data-volume-path ::restic-repository])) (def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password ::aws-access-key-id ::aws-secret-access-key @@ -37,9 +37,10 @@ (yaml/to-string (jira/generate-certificate config)) (yaml/to-string (jira/generate-ingress config)) (yaml/to-string (jira/generate-service))] - [(yaml/to-string (backup/generate-config config)) - (yaml/to-string (backup/generate-secret config)) - (yaml/to-string (backup/generate-cron))]))) + (when (contains? config :restic-repository) + [(yaml/to-string (backup/generate-config config)) + (yaml/to-string (backup/generate-secret config)) + (yaml/to-string (backup/generate-cron))])))) (defn-spec generate any? [my-config config? diff --git a/src/test/cljc/dda/c4k_jira/core_test.cljc b/src/test/cljc/dda/c4k_jira/core_test.cljc index 557c308..07602e7 100644 --- a/src/test/cljc/dda/c4k_jira/core_test.cljc +++ b/src/test/cljc/dda/c4k_jira/core_test.cljc @@ -24,4 +24,12 @@ :aws-access-key-id "aws-id" :aws-secret-access-key "aws-secret" :restic-password "restic-pw" - :restic-repository "restic-repository"}))))) + :restic-repository "restic-repository"})))) + (is (= 11 + (count (cut/k8s-objects {:fqdn "jira-neu.prod.meissa-gmbh.de" + :postgres-db-user "jira" + :postgres-db-password "jira-db-password" + :issuer :prod + :aws-access-key-id "aws-id" + :aws-secret-access-key "aws-secret" + :restic-password "restic-pw"})))))