mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-15 22:53:43 +00:00
packaging: Add push_to_registry()
This function will push a specific tag to a registry, whenever the PUSH_TO_REGISTRY environment variable is set, otherwise it's a no-op. This will be used in the future to avoid replicating that logic in every builder used by the kata-deploy scripts. Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
parent
e69a6f5749
commit
869827d77f
@ -47,8 +47,10 @@ docker build -q -t build-kata-deploy \
|
|||||||
docker run \
|
docker run \
|
||||||
-v $HOME/.docker:/root/.docker \
|
-v $HOME/.docker:/root/.docker \
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
|
-v "${kata_dir}:${kata_dir}" \
|
||||||
--env CI="${CI:-}" \
|
--env CI="${CI:-}" \
|
||||||
--env USER=${USER} -v "${kata_dir}:${kata_dir}" \
|
--env USER=${USER} \
|
||||||
|
--env PUSH_TO_REGISTRY="${PUSH_TO_REGISTRY:-"no"}" \
|
||||||
--rm \
|
--rm \
|
||||||
-w ${script_dir} \
|
-w ${script_dir} \
|
||||||
build-kata-deploy "${kata_deploy_create}" $@
|
build-kata-deploy "${kata_deploy_create}" $@
|
||||||
|
@ -9,6 +9,7 @@ export GOPATH=${GOPATH:-${HOME}/go}
|
|||||||
export tests_repo="${tests_repo:-github.com/kata-containers/tests}"
|
export tests_repo="${tests_repo:-github.com/kata-containers/tests}"
|
||||||
export tests_repo_dir="$GOPATH/src/$tests_repo"
|
export tests_repo_dir="$GOPATH/src/$tests_repo"
|
||||||
export BUILDER_REGISTRY="quay.io/kata-containers/builders"
|
export BUILDER_REGISTRY="quay.io/kata-containers/builders"
|
||||||
|
export PUSH_TO_REGISTRY="${PUSH_TO_REGISTRY:-"no"}"
|
||||||
|
|
||||||
this_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
this_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
@ -113,3 +114,18 @@ get_last_modification() {
|
|||||||
|
|
||||||
echo "$(git log -1 --pretty=format:"%H" ${file})${dirty}"
|
echo "$(git log -1 --pretty=format:"%H" ${file})${dirty}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# $1 - The tag to be pushed to the registry
|
||||||
|
# $2 - "yes" to use sudo, "no" otherwise
|
||||||
|
push_to_registry() {
|
||||||
|
local tag="${1}"
|
||||||
|
local use_sudo="${2:-"yes"}"
|
||||||
|
|
||||||
|
if [ "${PUSH_TO_REGISTRY}" == "yes" ]; then
|
||||||
|
if [ "${use_sudo}" == "yes" ]; then
|
||||||
|
sudo docker push ${tag}
|
||||||
|
else
|
||||||
|
docker push ${tag}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user