[Skip-CI] Generate API call for commit info
This commit is contained in:
parent
21f4a6c54e
commit
99bc14d62c
5 changed files with 37 additions and 29 deletions
|
@ -1,5 +1,5 @@
|
|||
#!/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 $SOURCEDIR
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/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() {
|
||||
curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$1 $GITREPOURL
|
||||
|
|
|
@ -98,6 +98,13 @@
|
|||
branch string?]
|
||||
(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?
|
||||
[col pred/map-or-seq?
|
||||
value-to-partly-match string?
|
||||
|
@ -204,10 +211,15 @@
|
|||
(->
|
||||
(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 "URL" (b64/encode
|
||||
(cm/replace-all-matching-values-by-new-value "REPOURL" (b64/encode
|
||||
(generate-gitrepourl
|
||||
gitea-host
|
||||
gitea-repo
|
||||
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
|
||||
data:
|
||||
AUTHTOKEN: TOKEN
|
||||
GITREPOURL: URL
|
||||
GITREPOURL: REPOURL
|
||||
GITCOMMITURL: COMMITURL
|
||||
|
||||
|
|
@ -214,30 +214,25 @@
|
|||
:branchname "main",
|
||||
:unique-name "test.io"}))))
|
||||
|
||||
|
||||
|
||||
(deftest should-generate-website-build-secret
|
||||
(is (= {:name-c1 "test-io-secret",
|
||||
:name-c2 "test-org-secret",
|
||||
:AUTHTOKEN-c1 (b64/encode "token1"),
|
||||
:AUTHTOKEN-c2 (b64/encode "token2"),
|
||||
:GITREPOURL-c1 (b64/encode "https://gitlab.org/api/v1/repos/dumpty/websitebau/archive/testname.zip"),
|
||||
:GITREPOURL-c2 (b64/encode "https://github.com/api/v1/repos/humpty/websitedachs/archive/testname.zip"),
|
||||
:app.kubernetes.part-of-c1 "test-io-website",
|
||||
:app.kubernetes.part-of-c2 "test-org-website"}
|
||||
(th/map-diff (cut/generate-website-build-secret {:unique-name "test.io",
|
||||
:authtoken "token1",
|
||||
:gitea-host "gitlab.org",
|
||||
:gitea-repo "websitebau",
|
||||
:username "dumpty",
|
||||
:branchname "testname",
|
||||
:fqdns ["test.de" "www.test.de" "test-it.de" "www.test-it.de"]}
|
||||
)
|
||||
(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"]})))))
|
||||
(is (= {:apiVersion "v1",
|
||||
:kind "Secret",
|
||||
:metadata {:name "test-io-secret", :labels {:app.kubernetes.part-of "test-io-website"}},
|
||||
:data
|
||||
{:AUTHTOKEN "YWJlZGpnYmFzZG9kag==",
|
||||
:GITREPOURL "aHR0cHM6Ly9naXRsYWIuZGUvYXBpL3YxL3JlcG9zL3NvbWV1c2VyL3JlcG8vYXJjaGl2ZS9tYWluLnppcA==",
|
||||
:GITCOMMITURL "aHR0cHM6Ly9naXRsYWIuZGUvYXBpL3YxL3JlcG9zL3NvbWV1c2VyL3JlcG8vZ2l0L2NvbW1pdHMvSEVBRA=="}}
|
||||
(cut/generate-website-build-secret {:authtoken "abedjgbasdodj",
|
||||
:gitea-host "gitlab.de",
|
||||
:username "someuser",
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||
:gitea-repo "repo",
|
||||
:sha256sum-output "123456789ab123cd345de script-file-name.sh",
|
||||
:issuer "staging",
|
||||
:branchname "main",
|
||||
:unique-name "test.io"}))))
|
||||
|
||||
(deftest should-generate-website-content-volume
|
||||
(is (= {:name-c1 "test-io-content-volume",
|
||||
|
|
Loading…
Reference in a new issue