ad1fd17aa5
Apparently the busybox implementation of `base64` will line-wrap long output strings. This meant that long username+password combinations could produce base64 that contained spurious "\n" characters, which then led to: ``` 2019/05/06 00:47:39 Unable to parse "/kaniko/.docker/config.json": invalid character '\n' in string literal ``` Fixed by just removing the newlines in base64 output. A "better" solution would use a different base64 implementation that avoided line-wrapping in the first place.
50 lines
1.2 KiB
Bash
Executable File
50 lines
1.2 KiB
Bash
Executable File
#!/busybox/sh
|
|
|
|
set -euo pipefail
|
|
|
|
export PATH=$PATH:/kaniko/
|
|
|
|
DOCKER_AUTH=`echo -n "${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}" | base64 | tr -d "\n"`
|
|
|
|
REGISTRY=${PLUGIN_REGISTRY:-https://index.docker.io/v1/}
|
|
|
|
cat > /kaniko/.docker/config.json <<DOCKERJSON
|
|
{
|
|
"auths": {
|
|
"${REGISTRY}": {
|
|
"auth": "${DOCKER_AUTH}"
|
|
}
|
|
}
|
|
}
|
|
DOCKERJSON
|
|
|
|
DOCKERFILE=${PLUGIN_DOCKERFILE:-Dockerfile}
|
|
CONTEXT=${PLUGIN_CONTEXT:-$PWD}
|
|
LOG=${PLUGIN_LOG:-info}
|
|
|
|
if [[ -n "${PLUGIN_TARGET:-}" ]]; then
|
|
TARGET="--target=${PLUGIN_TARGET}"
|
|
fi
|
|
|
|
if [[ "${PLUGIN_CACHE:-}" == "true" ]]; then
|
|
CACHE="--cache=true"
|
|
fi
|
|
|
|
if [[ -n "${PLUGIN_BUILD_ARGS:-}" ]]; then
|
|
BUILD_ARGS=$(echo "${PLUGIN_BUILD_ARGS}" | tr ',' '\n' | while read build_arg; do echo "--build-arg=${build_arg}"; done)
|
|
fi
|
|
|
|
if [[ -n "${PLUGIN_TAGS:-}" ]]; then
|
|
DESTINATIONS=$(echo "${PLUGIN_TAGS}" | tr ',' '\n' | while read tag; do echo "--destination=${PLUGIN_REPO}:${tag} "; done)
|
|
else
|
|
DESTINATIONS="--destination=${PLUGIN_REPO}:latest"
|
|
fi
|
|
|
|
/kaniko/executor -v ${LOG} \
|
|
--context=${CONTEXT} \
|
|
--dockerfile=${DOCKERFILE} \
|
|
${DESTINATIONS} \
|
|
${CACHE:-} \
|
|
${TARGET:-} \
|
|
${BUILD_ARGS:-}
|