From 686b20aa5601c1a5746eb8dd586add915fc6916f Mon Sep 17 00:00:00 2001 From: Clemens Geibel Date: Fri, 2 Jul 2021 16:45:25 +0200 Subject: [PATCH] Added secret.yaml --- .gitignore | 4 ++-- src/main/cljc/dda/c4k_jira/core.cljc | 6 ++++-- src/main/cljc/dda/c4k_jira/jira.cljc | 9 ++++++++- src/main/resources/jira/secret.yaml | 8 ++++++++ src/test/resources/valid-auth.edn | 1 + src/test/resources/valid-config.edn | 27 +++++++++++++++++++++++++++ valid-auth.edn | 2 ++ valid-config.edn | 1 + 8 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/jira/secret.yaml create mode 100644 src/test/resources/valid-auth.edn create mode 100644 src/test/resources/valid-config.edn create mode 100644 valid-auth.edn create mode 100644 valid-config.edn diff --git a/.gitignore b/.gitignore index ca00915..fd327f9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,6 @@ public/js/ *.iml .idea/ -valid-auth.edn -valid-config.edn +#valid-auth.edn +#valid-config.edn my-auth.edn diff --git a/src/main/cljc/dda/c4k_jira/core.cljc b/src/main/cljc/dda/c4k_jira/core.cljc index 3e9f53e..147ff90 100644 --- a/src/main/cljc/dda/c4k_jira/core.cljc +++ b/src/main/cljc/dda/c4k_jira/core.cljc @@ -12,14 +12,16 @@ (def config? (s/keys :req-un [::jira/fqdn] :opt-un [::jira/issuer])) -(def auth? (s/keys :req-un [])) +(def auth? (s/keys :req-un [::jira/db-user-name ::jira/db-user-password])) (defn-spec generate any? [my-config config? my-auth auth?] (let [resulting-config (merge config-defaults my-config)] (cs/join "\n" - [(yaml/to-string (jira/generate-persistent-volume)) + [(yaml/to-string (jira/generate-secret my-auth)) + "---" + (yaml/to-string (jira/generate-persistent-volume)) "---" (yaml/to-string (jira/generate-pvc)) "---" diff --git a/src/main/cljc/dda/c4k_jira/jira.cljc b/src/main/cljc/dda/c4k_jira/jira.cljc index 68ad4d5..5e7a76e 100644 --- a/src/main/cljc/dda/c4k_jira/jira.cljc +++ b/src/main/cljc/dda/c4k_jira/jira.cljc @@ -10,6 +10,13 @@ (s/def ::fqdn cm/fqdn-string?) (s/def ::issuer cm/letsencrypt-issuer?) +(defn generate-secret [auth] + (let [{:keys [db-user-name db-user-password]} auth] + (-> + (yaml/from-string (yaml/load-resource "jira/secret.yaml")) + (assoc-in [:data :db-user-name] db-user-name) + (assoc-in [:data :db-user-password] db-user-password)))) + (defn generate-certificate [config] (let [{:keys [fqdn issuer] :or {issuer :staging}} config @@ -39,6 +46,6 @@ (yaml/from-string (yaml/load-resource "jira/service.yaml"))) (defn generate-pod [config] - (let [{:keys [fqdn db-user-name db-user-password]}] + (let [{:keys [fqdn db-user-name db-user-password]} config] (-> (yaml/from-string (yaml/load-resource "jira/pod.yaml")) (assoc-in [:spec :containers :args] [fqdn, db-user-name, db-user-password])))) diff --git a/src/main/resources/jira/secret.yaml b/src/main/resources/jira/secret.yaml new file mode 100644 index 0000000..75d990c --- /dev/null +++ b/src/main/resources/jira/secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: jira-secret +type: Opaque +data: + db-user-name: admin + db-user-password: admin diff --git a/src/test/resources/valid-auth.edn b/src/test/resources/valid-auth.edn new file mode 100644 index 0000000..df4843c --- /dev/null +++ b/src/test/resources/valid-auth.edn @@ -0,0 +1 @@ +{:auth {}} \ No newline at end of file diff --git a/src/test/resources/valid-config.edn b/src/test/resources/valid-config.edn new file mode 100644 index 0000000..71187c8 --- /dev/null +++ b/src/test/resources/valid-config.edn @@ -0,0 +1,27 @@ +{:transform [{:source {:source-type :twitter + ;; optional, defaults to false + :include-replies? false + ;; optional, defaults to false + :include-rts? false + ;; Replace Twitter links by Nitter + :nitter-urls? false + ;; accounts you wish to mirror + :accounts ["arstechnica" "WIRED"]} + :target {:target-type :mastodon + ;; optional flag specifying wether the name of the account + ;; will be appended in the post, defaults to false + :append-screen-name? false + ;; optional visibility flag: direct, private, unlisted, public + ;; defaults to public + :visibility "unlisted" + ;; optional boolean to mark content as sensitive. Defaults to true. + :sensitive? true + ;; optional boolean defaults to false + ;; only sources containing media will be posted when set to true + :media-only? true + ;; optional limit for the post length. Defaults to 300. + :max-post-length 300 + ;; optional signature for posts. Defaults to "not present". + :signature "#newsbot"} + }] + :auth {}} \ No newline at end of file diff --git a/valid-auth.edn b/valid-auth.edn new file mode 100644 index 0000000..105dcdd --- /dev/null +++ b/valid-auth.edn @@ -0,0 +1,2 @@ +{:db-user-name "jira" + :db-user-password "jira-db-password"} \ No newline at end of file diff --git a/valid-config.edn b/valid-config.edn new file mode 100644 index 0000000..e8961b5 --- /dev/null +++ b/valid-config.edn @@ -0,0 +1 @@ +{:fqdn "keycloak.test.meissa-gmbh.de"} \ No newline at end of file