Execute script in subshell located in folder
Better handling of white spaces in input. Add test for creation of build jobs without sha256sum input.
This commit is contained in:
parent
5bd0eb88bc
commit
70f356a1a9
4 changed files with 35 additions and 5 deletions
|
@ -8,7 +8,7 @@ function get-and-unzip-website-data() {
|
|||
|
||||
function execute-scripts-when-existing {
|
||||
websitedir=$(ls $BUILDDIR)
|
||||
if [[ -e $BUILDDIR/$websitedir/$SCRIPTFILE ]]
|
||||
if [[ -f $BUILDDIR/$websitedir/$SCRIPTFILE ]]
|
||||
then
|
||||
checksum="$(sha256sum $BUILDDIR/$websitedir/$SCRIPTFILE)"
|
||||
if [[ "$SHA256SUM" == "$checksum" ]]
|
||||
|
@ -22,7 +22,7 @@ function execute-scripts-when-existing {
|
|||
exit 1
|
||||
fi
|
||||
else
|
||||
prinf "No script file provided, exiting."
|
||||
printf "No script file provided, exiting."
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
apt update > /dev/null;
|
||||
|
||||
apt install -y unzip rsync imagemagick
|
||||
apt install -y unzip rsync
|
||||
|
||||
mkdir /etc/lein/
|
||||
|
||||
|
|
|
@ -47,11 +47,15 @@
|
|||
|
||||
(defn-spec get-hash-from-sha256sum-output string?
|
||||
[sha256sum-output string?]
|
||||
(first (st/split sha256sum-output #" ")))
|
||||
(if (nil? sha256sum-output)
|
||||
nil
|
||||
(first (st/split sha256sum-output #"\ +"))))
|
||||
|
||||
(defn-spec get-file-name-from-sha256sum-output string?
|
||||
[sha256sum-output string?]
|
||||
(second (st/split sha256sum-output #" ")))
|
||||
(if (nil? sha256sum-output)
|
||||
nil
|
||||
(second (st/split (st/trim sha256sum-output) #"\ +"))))
|
||||
|
||||
(defn-spec replace-dots-by-minus string?
|
||||
[fqdn pred/fqdn-string?]
|
||||
|
|
|
@ -230,6 +230,32 @@
|
|||
:branchname "main",
|
||||
:unique-name "test.io"}))))
|
||||
|
||||
(deftest should-generate-website-initial-build-job-without-script-file
|
||||
(is (= {:apiVersion "batch/v1",
|
||||
:kind "Job",
|
||||
:metadata {:name "test-io-initial-build-job", :labels {:app.kubernetes.part-of "test-io-website"}},
|
||||
:spec
|
||||
{:template
|
||||
{:spec
|
||||
{:containers
|
||||
[{:image "domaindrivenarchitecture/c4k-website-build",
|
||||
:name "test-io-build-app",
|
||||
:imagePullPolicy "IfNotPresent",
|
||||
:command ["/entrypoint.sh"],
|
||||
:envFrom [{:secretRef {:name "test-io-secret"}}],
|
||||
:env [{:name "SHA256SUM", :value nil} {:name "SCRIPTFILE", :value nil}],
|
||||
:volumeMounts [{:name "content-volume", :mountPath "/var/www/html/website"}]}],
|
||||
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "test-io-content-volume"}}],
|
||||
:restartPolicy "OnFailure"}}}}
|
||||
(cut/generate-website-initial-build-job {:authtoken "abedjgbasdodj",
|
||||
:gitea-host "gitlab.de",
|
||||
:username "someuser",
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"],
|
||||
:gitea-repo "repo",
|
||||
:issuer "staging",
|
||||
:branchname "main",
|
||||
:unique-name "test.io"}))))
|
||||
|
||||
(deftest should-generate-website-build-secret
|
||||
(is (= {:name-c1 "test-io-secret",
|
||||
:name-c2 "test-org-secret",
|
||||
|
|
Loading…
Reference in a new issue