This repository has been archived on 2023-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
dex/scripts/check-go-version
Eric Chiang 18bbd94fba *: check go version before building
Add a script to check the Go version before building dex. This
gives a nice error message rather than just failing to compile.

With changes:

    $ go version
    go version go1.6.4 linux/amd64
    $ make
    ERROR: dex requires Go version 1.7+. Please update your Go installation: https://golang.org/dl/
    Makefile:93: recipe for target 'check-go-version' failed
    make: *** [check-go-version] Error 2

Checks only added for building the actual binary, not tests, since
this is aimed at users just starting off with the project.
2016-12-13 12:03:27 -08:00

34 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
set -e
VERSION=$( go version )
# For development versions of Go, these will be empty.
MAJOR_GOVERSION=$( echo -n "$VERSION" | grep -o 'go1\.[0-9]' || true )
FULL_GOVERSION=$( echo -n "$VERSION" | grep -o 'go1\.[0-9|\.]*' || true )
# The list of unsupported major go versions.
UNSUPPORTED=( "go1.0" "go1.1" "go1.2" "go1.3" "go1.4" "go1.5" "go1.6" )
# Minor go verisons which have known security vulnerabilities. Refuse to build with these.
#
# There aren't any security issues that impact dex in 1.7 but minor versions should be
# added here later if they do have issues.
KNOWN_INSECURE=( )
for V in "${UNSUPPORTED[@]}"; do
if [ "$V" = "$MAJOR_GOVERSION" ]; then
>&2 echo "ERROR: dex requires Go version 1.7+. Please update your Go installation: https://golang.org/dl/"
exit 2
fi
done
for V in "${KNOWN_INSECURE[@]}"; do
if [ "$V" = "$FULL_GOVERSION" ]; then
>&2 echo "Go version ${V} has known security vulnerabilities which impact dex. Please update your Go verison."
exit 2
fi
done