Preliminary cleanup of plugin.sh
This commit is contained in:
parent
bbbc4fa453
commit
2bac030dfd
13
plugin.sh
13
plugin.sh
@ -4,12 +4,12 @@ set -euo pipefail
|
||||
|
||||
export PATH=$PATH:/kaniko/
|
||||
|
||||
REGISTRY=${PLUGIN_REGISTRY:-index.docker.io}
|
||||
REGISTRY=${PLUGIN_REGISTRY:-docker.io}
|
||||
|
||||
if [ "${PLUGIN_USERNAME:-}" ] || [ "${PLUGIN_PASSWORD:-}" ]; then
|
||||
DOCKER_AUTH=`echo -n "${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}" | base64 | tr -d "\n"`
|
||||
|
||||
cat > /kaniko/.docker/config.json <<DOCKERJSON
|
||||
cat > /kaniko/.docker/config.json <<EOF
|
||||
{
|
||||
"auths": {
|
||||
"${REGISTRY}": {
|
||||
@ -17,7 +17,7 @@ if [ "${PLUGIN_USERNAME:-}" ] || [ "${PLUGIN_PASSWORD:-}" ]; then
|
||||
}
|
||||
}
|
||||
}
|
||||
DOCKERJSON
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ "${PLUGIN_JSON_KEY:-}" ];then
|
||||
@ -58,18 +58,19 @@ if [ -n "${PLUGIN_BUILD_ARGS_FROM_ENV:-}" ]; then
|
||||
BUILD_ARGS_FROM_ENV=$(echo "${PLUGIN_BUILD_ARGS_FROM_ENV}" | tr ',' '\n' | while read build_arg; do echo "--build-arg ${build_arg}=$(eval "echo \$$build_arg")"; done)
|
||||
fi
|
||||
|
||||
# TODO: Test auto_tag behavior; potential bugs might still be here
|
||||
# auto_tag, if set auto_tag: true, auto generate .tags file
|
||||
# support format Major.Minor.Release or start with `v`
|
||||
# docker tags: Major, Major.Minor, Major.Minor.Release and latest
|
||||
if [[ "${PLUGIN_AUTO_TAG:-}" == "true" ]]; then
|
||||
TAG=$(echo "${DRONE_TAG:-}" |sed 's/^v//g')
|
||||
part=$(echo "${TAG}" |tr '.' '\n' |wc -l)
|
||||
TAG=$(echo "${CI_COMMIT_TAG:-}" |sed 's/^v//g')
|
||||
tag_part_count=$(echo "${TAG}" | tr '.' '\n' |wc -l)
|
||||
# expect number
|
||||
echo ${TAG} | grep -E "[a-z-]" &>/dev/null && isNum=1 || isNum=0
|
||||
|
||||
if [ ! -n "${TAG:-}" ]; then
|
||||
echo "latest" > .tags
|
||||
elif [ ${isNum} -eq 1 -o ${part} -gt 3 ];then
|
||||
elif [ ${isNum} -eq 1 -o ${tag_part_count} -gt 3 ]; then
|
||||
echo "${TAG},latest" > .tags
|
||||
else
|
||||
major=$(echo "${TAG}" | awk -F'.' '{print $1}')
|
||||
|
Loading…
x
Reference in New Issue
Block a user