Files
virtual-kubelet/scripts/validate/check_version.sh
Sargun Dhillon 5f64eab109 Fix kubernetes version dependency checking script
We had locked to version v1.17.6 when this script was released. At the time,
it was also the current stable release, and what was presented by the
github API. It turns out the Github API does not present all tags. This
changes it to fetch the annotated tag from the upstream repo.
2020-06-22 22:53:27 -07:00

39 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
echo "Checking kubernetes version replacement / pinning"
readonly kubeversion=$(go list -m -f '{{.Version}}' k8s.io/kubernetes)
if [[ "${kubeversion}" =~ '^v.*' ]]; then
echo "Kube Version: ${kubeversion} in unexpected format, must start with v"
exit 1
fi
echo "Found kubernetes version: ${kubeversion}"
# We postfix the tag to search for with ^{}, as we want the annotated tag
readonly sha=$(git ls-remote --tags git@github.com:kubernetes/kubernetes.git "${kubeversion}^{}"|cut -f1 -d$'\t')
if [[ ! "${sha}" =~ ^[0-9a-f]{40}$ ]]; then
echo "Kube Sha: ${sha} in unexpected format"
exit 1
fi
echo "Found sha for kubernetes version ${kubeversion}: ${sha}"
# TODO: Check direct deps
# Humans should check the versions reference directly (i.e. bits under require) those should either read
# kubeversion, or v0.0.0
readonly short_sha=$(echo $sha|cut -b1-12)
readonly non_matching_versions=$(go list -m -json k8s.io/...|jq --arg short_sha "${short_sha}" 'select(.Replace != null) | select(.Replace.Version[-12:] != $short_sha)')
if [[ ! -z "${non_matching_versions}" ]]; then
echo "Found non-matching versions: ${non_matching_versions}"
exit 1
fi