From db4818fe1d3d4dc05a6c706fc545cae5ad117dd8 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 21 May 2024 18:03:45 +0100 Subject: [PATCH] ci: cache: Enforce tag length limit Container tags can be a maximum of 128 characters long so calculate the length of the arch suffix and then restrict the tag to this length subtracted from 128 Signed-off-by: stevenhorsman --- .../kata-deploy/local-build/kata-deploy-binaries.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh index 28c2213bfb..bb121542a2 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh @@ -1148,9 +1148,11 @@ handle_build() { echo "Pushing ${build_target} with tags: ${tags[*]}" for tag in "${tags[@]}"; do - # tags can only contain lowercase and uppercase letters, digits, underscores, periods, and hyphens, so - # filter out non-printable characers and then replace invalid printable characters with underscode - tag=("$(echo ${tag} | tr -dc '[:print:]' | tr -c '[a-zA-Z0-9\_\.\-]' _)-$(uname -m)") + # tags can only contain lowercase and uppercase letters, digits, underscores, periods, and hyphens + # and limited to 128 characters, so filter out non-printable characers, replace invalid printable + # characters with underscode and trim down to leave enough space for the arch suffix + tag_length_limit=$(expr 128 - $(echo "-$(uname -m)" | wc -c)) + tag=("$(echo ${tag} | tr -dc '[:print:]' | tr -c '[a-zA-Z0-9\_\.\-]' _ | head -c ${tag_length_limit})-$(uname -m)") case ${build_target} in kernel-nvidia-gpu) sudo oras push \