[Skip-Ci] Refactoring

This commit is contained in:
erik 2022-09-28 10:26:50 +02:00
parent 4a21794c04
commit bcad22b067
4 changed files with 12 additions and 12 deletions

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
function get-and-unzip-website-data() { function get-and-unzip-website-data() {
curl -H "Authorization: token $AUTHTOKEN" -O $REPOZIPURL # REPOZIPURL = https://your.gitea.host/api/v1/repos/<owner>/<repo>/archive/main.zip curl -H "Authorization: token $AUTHTOKEN" -O $GITREPOURL # GITREPURL = https://your.gitea.host/api/v1/repos/<owner>/<repo>/archive/main.zip
mkdir $BUILDDIR mkdir $BUILDDIR
unzip main.zip -D $BUILDDIR unzip main.zip -D $BUILDDIR
} }

View file

@ -137,10 +137,10 @@
(defn-spec generate-website-build-secret pred/map-or-seq? (defn-spec generate-website-build-secret pred/map-or-seq?
[auth auth?] [auth auth?]
(let [{:keys [fqdn (let [{:keys [fqdn
token authtoken
url]} auth] gitrepourl]} auth]
(-> (->
(yaml/load-as-edn "website/website-build-secret.yaml") (yaml/load-as-edn "website/website-build-secret.yaml")
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn fqdn)) (replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn fqdn))
(cm/replace-all-matching-values-by-new-value "TOKEN" (b64/encode token)) (cm/replace-all-matching-values-by-new-value "TOKEN" (b64/encode authtoken))
(cm/replace-all-matching-values-by-new-value "URL" (b64/encode url))))) (cm/replace-all-matching-values-by-new-value "URL" (b64/encode gitrepourl)))))

View file

@ -4,5 +4,5 @@ metadata:
name: NAME-secret name: NAME-secret
data: data:
AUTHTOKEN: TOKEN AUTHTOKEN: TOKEN
REPOZIPURL: URL GITREPOURL: URL

View file

@ -139,14 +139,14 @@
:name-c2 "test-com-secret", :name-c2 "test-com-secret",
:AUTHTOKEN-c1 (b64/encode "token1"), :AUTHTOKEN-c1 (b64/encode "token1"),
:AUTHTOKEN-c2 (b64/encode "token2"), :AUTHTOKEN-c2 (b64/encode "token2"),
:REPOZIPURL-c1 (b64/encode "test.de/user/repo.git"), :GITREPOURL-c1 (b64/encode "test.de/user/repo.git"),
:REPOZIPURL-c2 (b64/encode "test.com/user/repo.git")} :GITREPOURL-c2 (b64/encode "test.com/user/repo.git")}
(th/map-diff (cut/generate-website-build-secret {:fqdn "test.de" (th/map-diff (cut/generate-website-build-secret {:fqdn "test.de"
:token "token1" :authtoken "token1"
:url "test.de/user/repo.git"}) :gitrepourl "test.de/user/repo.git"})
(cut/generate-website-build-secret {:fqdn "test.com" (cut/generate-website-build-secret {:fqdn "test.com"
:token "token2" :authtoken "token2"
:url "test.com/user/repo.git"}))))) :gitrepourl "test.com/user/repo.git"})))))
(deftest should-generate-website-content-volume (deftest should-generate-website-content-volume