Only launch ssh agent if ssh keys are mounted in tekton.

This commit is contained in:
Tom Alexander 2024-10-20 21:27:52 -04:00
parent 3411d0cd39
commit 7ee31a1852
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -77,9 +77,13 @@ spec:
#!/usr/bin/env sh
#
set -euo pipefail
eval \$(ssh-agent)
ssh-add /tekton/creds/.ssh/id_*
exec buildctl-daemonless.sh build --ssh default=\$SSH_AUTH_SOCK "\${@}"
if [ -n "\$(find /tekton/creds/.ssh -maxdepth 1 -name 'id_*' -print -quit)" ]; then
eval \$(ssh-agent)
ssh-add /tekton/creds/.ssh/id_*
exec buildctl-daemonless.sh build --ssh default=\$SSH_AUTH_SOCK "\${@}"
else
exec buildctl-daemonless.sh build "\${@}"
fi
EOF
chmod +x /home/user/.config/buildkit/entrypoint.sh
volumeMounts: