Skip to content

Commit

Permalink
Use 'go list -m' instead of grep to look up versions
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
  • Loading branch information
brandond committed Aug 14, 2023
1 parent 7e658af commit c3ec545
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/validate-release
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ function parse_tag() {
fi
}

function get-module-version() {
go list -m -f '{{if .Replace}}{{.Replace.Version}}{{else}}{{.Version}}{{end}}' $1
}

function check_release_branch() {
TAG_BRANCH=$(git branch --all -q --contains $GIT_TAG | grep origin | grep -v origin$ | grep -v "HEAD" | sed -e 's/^[[:space:]]*//')
if [ "$TAG_BRANCH" == "remotes/origin/master" ]; then
K8S_VERSION_GO_MOD=$(grep 'k8s.io/kubernetes v' go.mod | head -n1 | awk '{print $2}' | cut -d. -f1-2)
K8S_VERSION_GO_MOD=$(get-module-version k8s.io/kubernetes | cut -d. -f1-2)
if [ "v$MAJOR.$MINOR" == "$K8S_VERSION_GO_MOD" ]; then
info "Tag $GIT_TAG is cut from master"
return
Expand Down

0 comments on commit c3ec545

Please sign in to comment.