[Skip-CI] Generate API call for commit info

merge-requests/4/head
erik 1 year ago
parent 21f4a6c54e
commit 99bc14d62c

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# curl -s -H "Authorization: token d92668fff6e005582dcb09c6590982a39b2523fc" https://repo.prod.meissa.de/api/v1/repos/meissa-intern/meissa-io/git/commits/HEAD | jq '.' # curl -s -H "Authorization: token xxxx" https://gitea.host/api/v1/repos/{owner}/{repo}/git/commits/HEAD | jq '.sha'
mkdir $BUILDDIR mkdir $BUILDDIR
mkdir $SOURCEDIR mkdir $SOURCEDIR

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# curl -s -H "Authorization: token xxxx" https://repo.prod.meissa.de/api/v1/repos/meissa-intern/meissa-io/git/commits/HEAD | jq '.sha' # curl -s -H "Authorization: token xxxx" https://gitea.host/api/v1/repos/{owner}/{repo}/git/commits/HEAD | jq '.sha'
function get-website-data() { function get-website-data() {
curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$1 $GITREPOURL curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$1 $GITREPOURL

@ -98,6 +98,13 @@
branch string?] branch string?]
(str "https://" host "/api/v1/repos/" user "/" repo "/archive/" branch ".zip")) (str "https://" host "/api/v1/repos/" user "/" repo "/archive/" branch ".zip"))
; https://your.gitea.host/api/v1/repos/<owner>/<repo>/git/commits/HEAD
(defn-spec generate-gitcommiturl string?
[host pred/fqdn-string?
repo string?
user string?]
(str "https://" host "/api/v1/repos/" user "/" repo "/git/" "commits/" "HEAD"))
(defn-spec replace-all-matching-substrings-beginning-with pred/map-or-seq? (defn-spec replace-all-matching-substrings-beginning-with pred/map-or-seq?
[col pred/map-or-seq? [col pred/map-or-seq?
value-to-partly-match string? value-to-partly-match string?
@ -204,10 +211,15 @@
(-> (->
(replace-common-data "website/website-build-secret.yaml" auth) (replace-common-data "website/website-build-secret.yaml" auth)
(cm/replace-all-matching-values-by-new-value "TOKEN" (b64/encode authtoken)) (cm/replace-all-matching-values-by-new-value "TOKEN" (b64/encode authtoken))
(cm/replace-all-matching-values-by-new-value "URL" (b64/encode (cm/replace-all-matching-values-by-new-value "REPOURL" (b64/encode
(generate-gitrepourl (generate-gitrepourl
gitea-host gitea-host
gitea-repo gitea-repo
username username
branchname)))))) branchname)))
(cm/replace-all-matching-values-by-new-value "COMMITURL" (b64/encode
(generate-gitcommiturl
gitea-host
gitea-repo
username))))))

@ -6,6 +6,7 @@ metadata:
app.kubernetes.part-of: NAME-website app.kubernetes.part-of: NAME-website
data: data:
AUTHTOKEN: TOKEN AUTHTOKEN: TOKEN
GITREPOURL: URL GITREPOURL: REPOURL
GITCOMMITURL: COMMITURL

@ -214,30 +214,25 @@
:branchname "main", :branchname "main",
:unique-name "test.io"})))) :unique-name "test.io"}))))
(deftest should-generate-website-build-secret (deftest should-generate-website-build-secret
(is (= {:name-c1 "test-io-secret", (is (= {:apiVersion "v1",
:name-c2 "test-org-secret", :kind "Secret",
:AUTHTOKEN-c1 (b64/encode "token1"), :metadata {:name "test-io-secret", :labels {:app.kubernetes.part-of "test-io-website"}},
:AUTHTOKEN-c2 (b64/encode "token2"), :data
:GITREPOURL-c1 (b64/encode "https://gitlab.org/api/v1/repos/dumpty/websitebau/archive/testname.zip"), {:AUTHTOKEN "YWJlZGpnYmFzZG9kag==",
:GITREPOURL-c2 (b64/encode "https://github.com/api/v1/repos/humpty/websitedachs/archive/testname.zip"), :GITREPOURL "aHR0cHM6Ly9naXRsYWIuZGUvYXBpL3YxL3JlcG9zL3NvbWV1c2VyL3JlcG8vYXJjaGl2ZS9tYWluLnppcA==",
:app.kubernetes.part-of-c1 "test-io-website", :GITCOMMITURL "aHR0cHM6Ly9naXRsYWIuZGUvYXBpL3YxL3JlcG9zL3NvbWV1c2VyL3JlcG8vZ2l0L2NvbW1pdHMvSEVBRA=="}}
:app.kubernetes.part-of-c2 "test-org-website"} (cut/generate-website-build-secret {:authtoken "abedjgbasdodj",
(th/map-diff (cut/generate-website-build-secret {:unique-name "test.io", :gitea-host "gitlab.de",
:authtoken "token1", :username "someuser",
:gitea-host "gitlab.org", :fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
:gitea-repo "websitebau", :gitea-repo "repo",
:username "dumpty", :sha256sum-output "123456789ab123cd345de script-file-name.sh",
:branchname "testname", :issuer "staging",
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]} :branchname "main",
) :unique-name "test.io"}))))
(cut/generate-website-build-secret {:unique-name "test.org",
:authtoken "token2",
:gitea-host "github.com",
:gitea-repo "websitedachs",
:username "humpty",
:branchname "testname",
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]})))))
(deftest should-generate-website-content-volume (deftest should-generate-website-content-volume
(is (= {:name-c1 "test-io-content-volume", (is (= {:name-c1 "test-io-content-volume",

Loading…
Cancel
Save