diff options
author | Jeremiah Snapp <jeremiah@chef.io> | 2022-03-01 07:37:27 -0500 |
---|---|---|
committer | Jeremiah Snapp <jeremiah@chef.io> | 2022-03-01 07:37:27 -0500 |
commit | 0e724e292ad004530e98aceb82a183b94415bd76 (patch) | |
tree | 35baccbcc1d3a67a9f93eaf2c5eb6581ebe07158 | |
parent | 9ee875b02980ef44b9b937f8f553599146a23aef (diff) | |
download | chef-0e724e292ad004530e98aceb82a183b94415bd76.tar.gz |
Fix docker tags
Signed-off-by: Jeremiah Snapp <jeremiah@chef.io>
-rwxr-xr-x | .expeditor/promote-docker-images.sh | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/.expeditor/promote-docker-images.sh b/.expeditor/promote-docker-images.sh index 47ccbb8a20..857fb3012f 100755 --- a/.expeditor/promote-docker-images.sh +++ b/.expeditor/promote-docker-images.sh @@ -11,10 +11,11 @@ docker_login_password="$(vault read -field=expeditor-full-access secret/docker/e # login to docker echo "--- Docker login so we can push to chef org" -docker login -u "${docker_login_user}" -p "${docker_login_password}" +docker login -u "$docker_login_user" -p "$docker_login_password" function create_and_push_manifest() { - manifest_tag="${1}" + local manifest_tag + manifest_tag="$1" echo "--- Creating manifest for ${manifest_tag}" docker manifest create "chef/chef:${manifest_tag}" \ @@ -25,18 +26,44 @@ function create_and_push_manifest() { docker manifest push "chef/chef:${manifest_tag}" } -# create the promoted channel docker image -create_and_push_manifest "${channel}" +# split the version components into integer variables +declare -i major_version minor_version _patch_version +IFS="."; read -r major_version minor_version _patch_version <<< "$version" -if [[ ${channel} == "stable" ]]; then - create_and_push_manifest "latest" +# mixlib-install uses package router's API which makes requests directly to Artifactory thereby providing up-to-date results +if mixlib-install download chef --url --channel stable --version "$major_version" &> /dev/null; then + major_version_is_in_omnibus_stable="true" +else + major_version_is_in_omnibus_stable="false" +fi - # split the version and add the tags for major and major.minor - IFS="."; read -ra split_version <<< "${version}" +latest_major_version_in_omnibus_current="$(mixlib-install download chef --version latest --channel current --attributes --url | tail -n +2 | jq -r '.version | split(".")[0]')" +latest_major_version_in_omnibus_stable="$(mixlib-install download chef --version latest --channel stable --attributes --url | tail -n +2 | jq -r '.version | split(".")[0]')" - # major version - create_and_push_manifest "${split_version[0]}" +if [[ "$channel" == "current" ]]; then + # Add major and major.minor version tags unless this major version has been promoted to the omnibus STABLE channel + if [[ "$major_version_is_in_omnibus_stable" = "false" ]] ; then + create_and_push_manifest "$major_version" + create_and_push_manifest "${major_version}.${minor_version}" + fi - # major.minor version - create_and_push_manifest "${split_version[0]}.${split_version[1]}" -fi
\ No newline at end of file + # Add "current" tag unless a newer major version has been promoted to the omnibus CURRENT channel + if [[ $major_version -ge $latest_major_version_in_omnibus_current ]]; then + create_and_push_manifest "current" + fi +elif [[ "$channel" == "stable" ]]; then + # Add major and major.minor version tags + create_and_push_manifest "$major_version" + create_and_push_manifest "${major_version}.${minor_version}" + + # Add "stable" tag unless a newer major version has been promoted to the omnibus STABLE channel + if [[ $major_version -ge $latest_major_version_in_omnibus_stable ]]; then + create_and_push_manifest "stable" + + # The "latest" docker tag is equivalent to the latest stable release + create_and_push_manifest "latest" + fi +else + echo "ERROR: Channel $channel not recognized" + exit 1 +fi |