Skip to content

Commit

Permalink
Trim namespace to 63 char limit (#27)
Browse files Browse the repository at this point in the history
* trim namespace to 63 char limit
  • Loading branch information
jgreat authored Apr 12, 2023
1 parent 44b4467 commit 00ab90d
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions util/metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,7 @@ is_set GITHUB_SHA
is_set GITHUB_OUTPUT

# OK if INPUT_PREFIX and GITHUB_REPOSITORY are unset.
namespace_prefix="$(normalize_ref_name ${INPUT_PREFIX:-$(base_prefix)})"
namespace_prefix="${namespace_prefix:-mc}"
# Make sure prefix is no longer than 10 chars, to leave room
# in the 63-char limit on k8s namespaces.
if [[ ${#namespace_prefix} -gt 10 ]]
then
namespace_prefix="${namespace_prefix:0:10}"
fi
namespace_prefix="$(normalize_ref_name "${INPUT_PREFIX:-$(base_prefix)}")"

sha="sha-${GITHUB_SHA:0:8}"

Expand Down Expand Up @@ -131,8 +124,8 @@ EOF
tag="${version}-${normalized_branch}.${GITHUB_RUN_NUMBER}.${sha}"
# Set docker metadata action compatible tag
docker_tag="type=raw,value=${tag}"
# Set namespace from normalized branch value
namespace="${namespace_prefix}-${normalized_branch}"
# Set namespace from prefix and normalized branch value. Cut down to 63
namespace=$(echo -n "${namespace_prefix}-${normalized_branch}" | cut -c -63 | sed -e 's!-*$!!')
;;
*)
echo "${GITHUB_REF_TYPE} is an unknown GitHub Reference Type"
Expand Down

0 comments on commit 00ab90d

Please sign in to comment.