From edca82924268887fb94bd0ebed1392f90636d7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Sun, 21 Nov 2021 11:07:44 +0100 Subject: [PATCH] tools: Rewrite the logic around kata-deploy changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can simplify the code a little bit, as at least now we group common operationr together. Hopefully this will improve the maintainability and the readability of the code. Signed-off-by: Fabiano FidĂȘncio --- .../release/update-repository-version.sh | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/tools/packaging/release/update-repository-version.sh b/tools/packaging/release/update-repository-version.sh index 6a5a3e7ff7..2fec951d23 100755 --- a/tools/packaging/release/update-repository-version.sh +++ b/tools/packaging/release/update-repository-version.sh @@ -150,24 +150,26 @@ bump_repo() { # -------------------+----------------+----------------+ info "Updating kata-deploy / kata-cleanup image tags" - if [ "${target_branch}" == "main" ] && [[ "${new_version}" =~ "rc" ]]; then - # case 2) - ## change the "latest" tag to the "#{new_version}" one - sed -i "s#quay.io/kata-containers/kata-deploy:latest#quay.io/kata-containers/kata-deploy:${new_version}#g" tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml - sed -i "s#quay.io/kata-containers/kata-deploy:latest#quay.io/kata-containers/kata-deploy:${new_version}#g" tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml + local version_to_replace="${current_version}" + local replacement="${new_version}" + if [ "${target_branch}" == "main" ]; then + if [[ "${new_version}" =~ "rc" ]]; then + ## this is the case 2) where we remove te kata-deploy / kata-cleanup stable files + git rm tools/packaging/kata-deploy/kata-deploy/base/kata-deploy-stable.yaml + git rm tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup-stable.yaml + else + ## this is the case 1) where we just do nothing + replacement="latest" + fi - git diff + version_to_replace="latest" + fi - git add tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml - git add tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml + if [ "${version_to_replace}" != "${replacement}" ]; then + ## this covers case 2) and 3), as on both of them we have changes on kata-deploy / kata-cleanup files + sed -i "s#quay.io/kata-containers/kata-deploy:${version_to_replace}#quay.io/kata-containers/kata-deploy:${replacement}#g" tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml + sed -i "s#quay.io/kata-containers/kata-deploy:${version_to_replace}#quay.io/kata-containers/kata-deploy:${replacement}#g" tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml - ## and remove the kata-deploy & kata-cleanup stable yaml files - git rm tools/packaging/kata-deploy/kata-deploy/base/kata-deploy-stable.yaml - git rm tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup-stable.yaml - elif [[ "${target_branch}" =~ "stable" ]]; then - # case 3) - sed -i "s#quay.io/kata-containers/kata-deploy:${current_version}#quay.io/kata-containers/kata-deploy:${new_version}#g" tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml - sed -i "s#quay.io/kata-containers/kata-deploy:${current_version}#quay.io/kata-containers/kata-deploy:${new_version}#g" tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml git diff git add tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml