Skip to content

Commit

Permalink
Moved a function (needed by helm too)
Browse files Browse the repository at this point in the history
  • Loading branch information
mihxil committed Nov 16, 2024
1 parent 5a9c573 commit 634a1d2
Showing 2 changed files with 23 additions and 26 deletions.
20 changes: 20 additions & 0 deletions scripts/dockerfile-functions.sh
Original file line number Diff line number Diff line change
@@ -65,4 +65,24 @@ get_artifact_versions() {
echo "Using image artifact: \"$IMAGE\" (tag: \"$IMAGE_TAG\", full: \"$FULL_IMAGE_NAME\")"
}

echo "Define determine_image_version"
determine_image_version() {
if [ "$IMAGE_TAG" = '' ] ; then
echo "No IMAGE_TAG defined. Breaking build. This must be defined in job rule!"
exit 1
fi
if [ "$IMAGE_NAME" = '' ] ; then
echo "No IMAGE_NAME defined. Taking from os_app_name"
IMAGE_NAME=$(os_app_name)
export IMAGE_NAME
fi
# used by plain docker builds
if [ "$AS_LATEST" = 'true' ] ; then
export LATEST="--destination $REGISTRY/$IMAGE_NAME"
else
export LATEST=
fi
export IMAGE=$REGISTRY/$IMAGE_NAME:$IMAGE_TAG
echo "IMAGE: $IMAGE"
}

29 changes: 3 additions & 26 deletions scripts/kaniko-gitlab-functions.sh
Original file line number Diff line number Diff line change
@@ -30,34 +30,11 @@ fi
# which will have the same effect, but I think this is robust, because no need for fiddling with 'need=<previous job>',
# which is confusing and error-prone.
store_image_version() {
echo "Storing variables in job.env"
echo "IMAGE_TAG=$IMAGE_TAG" | tee job.env
echo "IMAGE=$IMAGE" | tee -a job.env
echo "IMAGE_NAME=$IMAGE_NAME" | tee -a job.env
echo "FULL_IMAGE_NAME=$FULL_IMAGE_NAME" | tee -a job.env
echo "PROJECT_VERSION=$PROJECT_VERSION" | tee -a job.env
echo "OS_APPLICATIONS=$OS_APPLICATIONS" | tee -a job.env
#echo AS_LATEST=${AS_LATEST:-'false'}

}

echo "Define determine_image_version"
# If store_image_version was called earlier in the pipeline, the the results of this are in job.env
determine_image_version() {

# used by plain docker builds
if [ "$AS_LATEST" = 'true' ] ; then
export LATEST="--destination $REGISTRY/$IMAGE_NAME"
else
export LATEST=
fi

if [ "$IMAGE_TAG" = '' ] ; then
echo "No IMAGE_TAG defined. Breaking build. This must be defined in job rule!"
exit 1
fi
if [ "$IMAGE_NAME" = '' ] ; then
echo "No IMAGE_NAME defined. Taking from os_app_name"
IMAGE_NAME=$(os_app_name)
export IMAGE_NAME
fi
export IMAGE=$REGISTRY/$IMAGE_NAME:$IMAGE_TAG
echo "IMAGE: $IMAGE"
}

0 comments on commit 634a1d2

Please sign in to comment.