Skip to content

Commit

Permalink
feat: update Codenotary VCN to 1.0.1
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
  • Loading branch information
ckotzbauer committed Sep 24, 2022
1 parent 849134b commit ec17ccb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
4 changes: 2 additions & 2 deletions job-images/vcn/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM codenotary/vcn:0.9.20 as vcn
FROM docker:20.10.18-dind
FROM codenotary/vcn:v1.0.1 as vcn
FROM alpine:3.16

COPY --from=vcn /bin/vcn /bin/vcn
COPY entrypoint.sh /
Expand Down
24 changes: 4 additions & 20 deletions job-images/vcn/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/bin/bash

echo "Start dockerd in background"
dockerd &
sleep 5 # TODO: Use better wait mechanism

ERRORCOUNT=0
inc_errors() {
(( ERRORCOUNT += 1 ))
Expand All @@ -18,17 +14,17 @@ for img in $(echo "${CONFIG}" | jq -r '.[] | @base64'); do
echo "${img}" | base64 -d | jq -r ${1}
}

HOST=$(_jq '."registry-host"')
USER=$(_jq '."registry-user"')
PASSWORD=$(_jq '."registry-password"')
IMAGE=$(_jq '."image"')
PODS=$(_jq '."pods"')
echo "Process image ${IMAGE}"
VCN_PULL_CREDS=""

if [ ! -z "${USER}" ] && [ ! -z "${PASSWORD}" ]
then
echo "Login to ${HOST}"
docker login -u "${USER}" -p "${PASSWORD}" "${HOST}"
VCN_PULL_CREDS="--image-registry-user ${USER} --image-registry-password ${PASSWORD}"
echo "Using provided pull-credentials"
fi

# Join Pods, Namespaces and Clusters with "," and form the attributes for notarization.
Expand All @@ -37,22 +33,10 @@ for img in $(echo "${CONFIG}" | jq -r '.[] | @base64'); do
CLUSTER_STRING=$(echo $PODS | jq -r '[.[].cluster] | join(",")')

VCN_ATTR="--attr pod=${POD_STRING} --attr namespace=${NAMESPACE_STRING} --attr cluster=${CLUSTER_STRING}"
VCN_ARGS=("${VCN_ATTR}" "${VCN_EXTRA_ARGS:-""}" --bom docker://"${IMAGE}")
VCN_ARGS=("${VCN_PULL_CREDS}" "${VCN_ATTR}" "${VCN_EXTRA_ARGS:-""}" --bom image://"${IMAGE}")

docker pull "${IMAGE}" -q
vcn notarize ${VCN_ARGS[@]}
docker rm -f $(docker ps -aq)
docker rmi "${IMAGE}"

if [ ! -z "${USER}" ] && [ ! -z "${PASSWORD}" ]
then
echo "Logout from ${HOST}"
docker logout "${HOST}"
fi
done

vcn logout
echo "Kill dockerd"
pkill dockerd

exit $ERRORCOUNT

0 comments on commit ec17ccb

Please sign in to comment.