Skip to content

Commit

Permalink
Handle conflicts between additional and default labels
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Oct 3, 2024
1 parent 38f6119 commit 100d234
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 24 deletions.
22 changes: 16 additions & 6 deletions task/buildah-oci-ta/0.2/buildah-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,25 @@ spec:
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume ${mount_point}:${YUM_REPOS_D_TARGET}"
fi
LABELS=(
"--label" "build-date=$(date -u +'%Y-%m-%dT%H:%M:%S')"
"--label" "architecture=$(uname -m)"
"--label" "vcs-type=git"
DEFAULT_LABELS=(
"build-date=$(date -u +'%Y-%m-%dT%H:%M:%S')"
"architecture=$(uname -m)"
"vcs-type=git"
)
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")
[ -n "$COMMIT_SHA" ] && DEFAULT_LABELS+=("vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && DEFAULT_LABELS+=("quay.expires-after=$IMAGE_EXPIRES_AFTER")
LABELS=()
for label in "${ADDITIONAL_LABELS[@]}"; do
echo "Adding label from param $label"
LABELS+=("--label" "$label")
done
for label in "${DEFAULT_LABELS[@]}"; do
if [[ ${ADDITIONAL_LABELS[*]} =~ ${label//=*/} ]]; then
echo "Dropping default label $label"
continue
fi
echo "Adding default label $label"
LABELS+=("--label" "$label")
done
Expand Down
22 changes: 16 additions & 6 deletions task/buildah-remote-oci-ta/0.2/buildah-remote-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -446,15 +446,25 @@ spec:
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume ${mount_point}:${YUM_REPOS_D_TARGET}"
fi
LABELS=(
"--label" "build-date=$(date -u +'%Y-%m-%dT%H:%M:%S')"
"--label" "architecture=$(uname -m)"
"--label" "vcs-type=git"
DEFAULT_LABELS=(
"build-date=$(date -u +'%Y-%m-%dT%H:%M:%S')"
"architecture=$(uname -m)"
"vcs-type=git"
)
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")
[ -n "$COMMIT_SHA" ] && DEFAULT_LABELS+=("vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && DEFAULT_LABELS+=("quay.expires-after=$IMAGE_EXPIRES_AFTER")
LABELS=()
for label in "${ADDITIONAL_LABELS[@]}"; do
echo "Adding label from param $label"
LABELS+=("--label" "$label")
done
for label in "${DEFAULT_LABELS[@]}"; do
if [[ ${ADDITIONAL_LABELS[*]} =~ ${label//=*/} ]]; then
echo "Dropping default label $label"
continue
fi
echo "Adding default label $label"
LABELS+=("--label" "$label")
done
Expand Down
22 changes: 16 additions & 6 deletions task/buildah-remote/0.2/buildah-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,25 @@ spec:
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume ${mount_point}:${YUM_REPOS_D_TARGET}"
fi
LABELS=(
"--label" "build-date=$(date -u +'%Y-%m-%dT%H:%M:%S')"
"--label" "architecture=$(uname -m)"
"--label" "vcs-type=git"
DEFAULT_LABELS=(
"build-date=$(date -u +'%Y-%m-%dT%H:%M:%S')"
"architecture=$(uname -m)"
"vcs-type=git"
)
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")
[ -n "$COMMIT_SHA" ] && DEFAULT_LABELS+=("vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && DEFAULT_LABELS+=("quay.expires-after=$IMAGE_EXPIRES_AFTER")
LABELS=()
for label in "${ADDITIONAL_LABELS[@]}"; do
echo "Adding label from param $label"
LABELS+=("--label" "$label")
done
for label in "${DEFAULT_LABELS[@]}"; do
if [[ ${ADDITIONAL_LABELS[*]} =~ ${label//=*} ]]; then
echo "Dropping default label $label"
continue
fi
echo "Adding default label $label"
LABELS+=("--label" "$label")
done
Expand Down
22 changes: 16 additions & 6 deletions task/buildah/0.2/buildah.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,25 @@ spec:
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume ${mount_point}:${YUM_REPOS_D_TARGET}"
fi
LABELS=(
"--label" "build-date=$(date -u +'%Y-%m-%dT%H:%M:%S')"
"--label" "architecture=$(uname -m)"
"--label" "vcs-type=git"
DEFAULT_LABELS=(
"build-date=$(date -u +'%Y-%m-%dT%H:%M:%S')"
"architecture=$(uname -m)"
"vcs-type=git"
)
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")
[ -n "$COMMIT_SHA" ] && DEFAULT_LABELS+=("vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && DEFAULT_LABELS+=("quay.expires-after=$IMAGE_EXPIRES_AFTER")
LABELS=()
for label in "${ADDITIONAL_LABELS[@]}"; do
echo "Adding label from param $label"
LABELS+=("--label" "$label")
done
for label in "${DEFAULT_LABELS[@]}"; do
if [[ ${ADDITIONAL_LABELS[*]} =~ ${label//=*} ]]; then
echo "Dropping default label $label"
continue
fi
echo "Adding default label $label"
LABELS+=("--label" "$label")
done
Expand Down

0 comments on commit 100d234

Please sign in to comment.