Commit 97556201 authored by Jonas Ådahl's avatar Jonas Ådahl
Browse files

Add FDO_UPSTREAM_REGISTRY to specify registry path

This adds a new variable that complements FDO_UPSTREAM_REPO. It will
default to whatever FDO_UPSTREAM_REPO is set to but turned into lower
case, as that is usually where the container image registry is located
it for a project.

It is still possible to set the FDO_UPSTREAM_REGISTRY when using the
templates, to override the derived default.

Closes: #22

Signed-off-by: Jonas Ådahl's avatarJonas Ådahl <jadahl@gmail.com>
parent 8bea1f04
Pipeline #231829 passed with stages
in 1 minute and 36 seconds
......@@ -27,6 +27,12 @@
export FDO_REPO_SUFFIX={{distribution}}/$DISTRO_VERSION ;
fi
- if [[ x"$FDO_UPSTREAM_REPO" != x"" ]] &&
[[ x"$FDO_UPSTREAM_REGISTRY" == x"" ]] ;
then
export FDO_UPSTREAM_REGISTRY="$(echo $FDO_UPSTREAM_REPO | tr '[:upper:]' '[:lower:]')" ;
fi
- export BUILDAH_RUN="buildah run --isolation chroot"
- export BUILDAH_COMMIT="buildah commit --format docker"
- export BUILDAH_FROM="buildah from --isolation=chroot"
......@@ -56,11 +62,11 @@
skopeo inspect docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG | jq '[.Digest, .Layers]' > local_sha
# check if our image is already in the upstream registry
if [[ -z "$FDO_UPSTREAM_REPO" ]]
if [[ -z "$FDO_UPSTREAM_REGISTRY" ]]
then
echo "WARNING! Variable \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
echo "WARNING! Variable \$FDO_UPSTREAM_REGISTRY or \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
else
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
fi
# reenable exit on failure
......@@ -76,10 +82,10 @@
# copy the original image into the current project registry namespace
# we do 2 attempts with skopeo copy at most
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG || \
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG
exit 0
......@@ -256,6 +262,11 @@
#
# The GitLab project path to the upstream project
#
# .. attribute:: FDO_UPSTREAM_REGISTRY
#
# The GitLab project path to the upstream registry. If not defined,
# it will default to $FDO_UPSTREAM_REPO changed to lower case.
#
# .. attribute:: FDO_REPO_SUFFIX
#
# The repository name suffix to use, see below.
......
......@@ -22,6 +22,12 @@
export FDO_REPO_SUFFIX=alpine/$DISTRO_VERSION ;
fi
- if [[ x"$FDO_UPSTREAM_REPO" != x"" ]] &&
[[ x"$FDO_UPSTREAM_REGISTRY" == x"" ]] ;
then
export FDO_UPSTREAM_REGISTRY="$(echo $FDO_UPSTREAM_REPO | tr '[:upper:]' '[:lower:]')" ;
fi
- export BUILDAH_RUN="buildah run --isolation chroot"
- export BUILDAH_COMMIT="buildah commit --format docker"
- export BUILDAH_FROM="buildah from --isolation=chroot"
......@@ -51,11 +57,11 @@
skopeo inspect docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG | jq '[.Digest, .Layers]' > local_sha
# check if our image is already in the upstream registry
if [[ -z "$FDO_UPSTREAM_REPO" ]]
if [[ -z "$FDO_UPSTREAM_REGISTRY" ]]
then
echo "WARNING! Variable \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
echo "WARNING! Variable \$FDO_UPSTREAM_REGISTRY or \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
else
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
fi
# reenable exit on failure
......@@ -71,10 +77,10 @@
# copy the original image into the current project registry namespace
# we do 2 attempts with skopeo copy at most
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG || \
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG
exit 0
......@@ -226,6 +232,11 @@
#
# The GitLab project path to the upstream project
#
# .. attribute:: FDO_UPSTREAM_REGISTRY
#
# The GitLab project path to the upstream registry. If not defined,
# it will default to $FDO_UPSTREAM_REPO changed to lower case.
#
# .. attribute:: FDO_REPO_SUFFIX
#
# The repository name suffix to use, see below.
......
......@@ -22,6 +22,12 @@
export FDO_REPO_SUFFIX=arch/$DISTRO_VERSION ;
fi
- if [[ x"$FDO_UPSTREAM_REPO" != x"" ]] &&
[[ x"$FDO_UPSTREAM_REGISTRY" == x"" ]] ;
then
export FDO_UPSTREAM_REGISTRY="$(echo $FDO_UPSTREAM_REPO | tr '[:upper:]' '[:lower:]')" ;
fi
- export BUILDAH_RUN="buildah run --isolation chroot"
- export BUILDAH_COMMIT="buildah commit --format docker"
- export BUILDAH_FROM="buildah from --isolation=chroot"
......@@ -51,11 +57,11 @@
skopeo inspect docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG | jq '[.Digest, .Layers]' > local_sha
# check if our image is already in the upstream registry
if [[ -z "$FDO_UPSTREAM_REPO" ]]
if [[ -z "$FDO_UPSTREAM_REGISTRY" ]]
then
echo "WARNING! Variable \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
echo "WARNING! Variable \$FDO_UPSTREAM_REGISTRY or \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
else
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
fi
# reenable exit on failure
......@@ -71,10 +77,10 @@
# copy the original image into the current project registry namespace
# we do 2 attempts with skopeo copy at most
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG || \
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG
exit 0
......@@ -226,6 +232,11 @@
#
# The GitLab project path to the upstream project
#
# .. attribute:: FDO_UPSTREAM_REGISTRY
#
# The GitLab project path to the upstream registry. If not defined,
# it will default to $FDO_UPSTREAM_REPO changed to lower case.
#
# .. attribute:: FDO_REPO_SUFFIX
#
# The repository name suffix to use, see below.
......
......@@ -21,6 +21,12 @@
export FDO_REPO_SUFFIX=centos/$DISTRO_VERSION ;
fi
- if [[ x"$FDO_UPSTREAM_REPO" != x"" ]] &&
[[ x"$FDO_UPSTREAM_REGISTRY" == x"" ]] ;
then
export FDO_UPSTREAM_REGISTRY="$(echo $FDO_UPSTREAM_REPO | tr '[:upper:]' '[:lower:]')" ;
fi
- export BUILDAH_RUN="buildah run --isolation chroot"
- export BUILDAH_COMMIT="buildah commit --format docker"
- export BUILDAH_FROM="buildah from --isolation=chroot"
......@@ -50,11 +56,11 @@
skopeo inspect docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG | jq '[.Digest, .Layers]' > local_sha
# check if our image is already in the upstream registry
if [[ -z "$FDO_UPSTREAM_REPO" ]]
if [[ -z "$FDO_UPSTREAM_REGISTRY" ]]
then
echo "WARNING! Variable \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
echo "WARNING! Variable \$FDO_UPSTREAM_REGISTRY or \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
else
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
fi
# reenable exit on failure
......@@ -70,10 +76,10 @@
# copy the original image into the current project registry namespace
# we do 2 attempts with skopeo copy at most
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG || \
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG
exit 0
......@@ -231,6 +237,11 @@
#
# The GitLab project path to the upstream project
#
# .. attribute:: FDO_UPSTREAM_REGISTRY
#
# The GitLab project path to the upstream registry. If not defined,
# it will default to $FDO_UPSTREAM_REPO changed to lower case.
#
# .. attribute:: FDO_REPO_SUFFIX
#
# The repository name suffix to use, see below.
......
......@@ -21,6 +21,12 @@
export FDO_REPO_SUFFIX=debian/$DISTRO_VERSION ;
fi
- if [[ x"$FDO_UPSTREAM_REPO" != x"" ]] &&
[[ x"$FDO_UPSTREAM_REGISTRY" == x"" ]] ;
then
export FDO_UPSTREAM_REGISTRY="$(echo $FDO_UPSTREAM_REPO | tr '[:upper:]' '[:lower:]')" ;
fi
- export BUILDAH_RUN="buildah run --isolation chroot"
- export BUILDAH_COMMIT="buildah commit --format docker"
- export BUILDAH_FROM="buildah from --isolation=chroot"
......@@ -50,11 +56,11 @@
skopeo inspect docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG | jq '[.Digest, .Layers]' > local_sha
# check if our image is already in the upstream registry
if [[ -z "$FDO_UPSTREAM_REPO" ]]
if [[ -z "$FDO_UPSTREAM_REGISTRY" ]]
then
echo "WARNING! Variable \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
echo "WARNING! Variable \$FDO_UPSTREAM_REGISTRY or \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
else
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
fi
# reenable exit on failure
......@@ -70,10 +76,10 @@
# copy the original image into the current project registry namespace
# we do 2 attempts with skopeo copy at most
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG || \
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG
exit 0
......@@ -241,6 +247,11 @@
#
# The GitLab project path to the upstream project
#
# .. attribute:: FDO_UPSTREAM_REGISTRY
#
# The GitLab project path to the upstream registry. If not defined,
# it will default to $FDO_UPSTREAM_REPO changed to lower case.
#
# .. attribute:: FDO_REPO_SUFFIX
#
# The repository name suffix to use, see below.
......
......@@ -21,6 +21,12 @@
export FDO_REPO_SUFFIX=fedora/$DISTRO_VERSION ;
fi
- if [[ x"$FDO_UPSTREAM_REPO" != x"" ]] &&
[[ x"$FDO_UPSTREAM_REGISTRY" == x"" ]] ;
then
export FDO_UPSTREAM_REGISTRY="$(echo $FDO_UPSTREAM_REPO | tr '[:upper:]' '[:lower:]')" ;
fi
- export BUILDAH_RUN="buildah run --isolation chroot"
- export BUILDAH_COMMIT="buildah commit --format docker"
- export BUILDAH_FROM="buildah from --isolation=chroot"
......@@ -50,11 +56,11 @@
skopeo inspect docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG | jq '[.Digest, .Layers]' > local_sha
# check if our image is already in the upstream registry
if [[ -z "$FDO_UPSTREAM_REPO" ]]
if [[ -z "$FDO_UPSTREAM_REGISTRY" ]]
then
echo "WARNING! Variable \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
echo "WARNING! Variable \$FDO_UPSTREAM_REGISTRY or \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
else
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
fi
# reenable exit on failure
......@@ -70,10 +76,10 @@
# copy the original image into the current project registry namespace
# we do 2 attempts with skopeo copy at most
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG || \
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG
exit 0
......@@ -231,6 +237,11 @@
#
# The GitLab project path to the upstream project
#
# .. attribute:: FDO_UPSTREAM_REGISTRY
#
# The GitLab project path to the upstream registry. If not defined,
# it will default to $FDO_UPSTREAM_REPO changed to lower case.
#
# .. attribute:: FDO_REPO_SUFFIX
#
# The repository name suffix to use, see below.
......
......@@ -21,6 +21,12 @@
export FDO_REPO_SUFFIX=ubuntu/$DISTRO_VERSION ;
fi
- if [[ x"$FDO_UPSTREAM_REPO" != x"" ]] &&
[[ x"$FDO_UPSTREAM_REGISTRY" == x"" ]] ;
then
export FDO_UPSTREAM_REGISTRY="$(echo $FDO_UPSTREAM_REPO | tr '[:upper:]' '[:lower:]')" ;
fi
- export BUILDAH_RUN="buildah run --isolation chroot"
- export BUILDAH_COMMIT="buildah commit --format docker"
- export BUILDAH_FROM="buildah from --isolation=chroot"
......@@ -50,11 +56,11 @@
skopeo inspect docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG | jq '[.Digest, .Layers]' > local_sha
# check if our image is already in the upstream registry
if [[ -z "$FDO_UPSTREAM_REPO" ]]
if [[ -z "$FDO_UPSTREAM_REGISTRY" ]]
then
echo "WARNING! Variable \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
echo "WARNING! Variable \$FDO_UPSTREAM_REGISTRY or \$FDO_UPSTREAM_REPO is undefined, cannot check for images"
else
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG | jq '[.Digest, .Layers]' > upstream_sha
fi
# reenable exit on failure
......@@ -70,10 +76,10 @@
# copy the original image into the current project registry namespace
# we do 2 attempts with skopeo copy at most
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG || \
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY/$FDO_UPSTREAM_REGISTRY/$FDO_REPO_SUFFIX:$DISTRO_TAG \
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG
exit 0
......@@ -240,6 +246,11 @@
#
# The GitLab project path to the upstream project
#
# .. attribute:: FDO_UPSTREAM_REGISTRY
#
# The GitLab project path to the upstream registry. If not defined,
# it will default to $FDO_UPSTREAM_REPO changed to lower case.
#
# .. attribute:: FDO_REPO_SUFFIX
#
# The repository name suffix to use, see below.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment