mirror of https://github.com/k3s-io/k3s
Demand at least go1.6
parent
cbf886c7f4
commit
527cb50583
|
@ -253,6 +253,33 @@ kube::golang::create_gopath_tree() {
|
|||
ln -s "${KUBE_ROOT}" "${go_pkg_dir}"
|
||||
}
|
||||
|
||||
# Ensure the go tool exists and is a viable version.
|
||||
kube::golang::verify_go_version() {
|
||||
if [[ -z "$(which go)" ]]; then
|
||||
kube::log::usage_from_stdin <<EOF
|
||||
Can't find 'go' in PATH, please fix and retry.
|
||||
See http://golang.org/doc/install for installation instructions.
|
||||
EOF
|
||||
return 2
|
||||
fi
|
||||
|
||||
# Travis continuous build uses a head go release that doesn't report
|
||||
# a version number, so we skip this check on Travis. It's unnecessary
|
||||
# there anyway.
|
||||
if [[ "${TRAVIS:-}" != "true" ]]; then
|
||||
local go_version
|
||||
go_version=($(go version))
|
||||
if [[ "${go_version[2]}" < "go1.6" ]]; then
|
||||
kube::log::usage_from_stdin <<EOF
|
||||
Detected go version: ${go_version[*]}.
|
||||
Kubernetes requires go version 1.6 or greater.
|
||||
Please install Go version 1.6 or later.
|
||||
EOF
|
||||
return 2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# kube::golang::setup_env will check that the `go` commands is available in
|
||||
# ${PATH}. If not running on Travis, it will also check that the Go version is
|
||||
# good enough for the Kubernetes build.
|
||||
|
@ -266,32 +293,10 @@ kube::golang::create_gopath_tree() {
|
|||
# env-var GO15VENDOREXPERIMENT=1
|
||||
# current directory is within GOPATH
|
||||
kube::golang::setup_env() {
|
||||
kube::golang::verify_go_version
|
||||
|
||||
kube::golang::create_gopath_tree
|
||||
|
||||
if [[ -z "$(which go)" ]]; then
|
||||
kube::log::usage_from_stdin <<EOF
|
||||
Can't find 'go' in PATH, please fix and retry.
|
||||
See http://golang.org/doc/install for installation instructions.
|
||||
EOF
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Travis continuous build uses a head go release that doesn't report
|
||||
# a version number, so we skip this check on Travis. It's unnecessary
|
||||
# there anyway.
|
||||
if [[ "${TRAVIS:-}" != "true" ]]; then
|
||||
local go_version
|
||||
go_version=($(go version))
|
||||
if [[ "${go_version[2]}" < "go1.4" ]]; then
|
||||
kube::log::usage_from_stdin <<EOF
|
||||
Detected go version: ${go_version[*]}.
|
||||
Kubernetes requires go version 1.4 or greater.
|
||||
Please install Go version 1.4 or later.
|
||||
EOF
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
export GOPATH=${KUBE_GOPATH}
|
||||
|
||||
# Append KUBE_EXTRA_GOPATH to the GOPATH if it is defined.
|
||||
|
@ -441,16 +446,12 @@ kube::golang::build_binaries_for_platform() {
|
|||
for test in "${tests[@]:+${tests[@]}}"; do
|
||||
local outfile=$(kube::golang::output_filename_for_binary "${test}" \
|
||||
"${platform}")
|
||||
# Go 1.4 added -o to control where the binary is saved, but Go 1.3 doesn't
|
||||
# have this flag. Whenever we deprecate go 1.3, update to use -o instead of
|
||||
# changing into the output directory.
|
||||
mkdir -p "$(dirname ${outfile})"
|
||||
pushd "$(dirname ${outfile})" >/dev/null
|
||||
go test -c \
|
||||
"${goflags[@]:+${goflags[@]}}" \
|
||||
-ldflags "${goldflags}" \
|
||||
-o "${outfile}" \
|
||||
"$(dirname ${test})"
|
||||
popd >/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
@ -107,18 +107,11 @@ kube::version::load_version_vars() {
|
|||
source "${version_file}"
|
||||
}
|
||||
|
||||
# golang 1.5+ wants `-X key=val`, but golang 1.4- REQUIRES `-X key val`
|
||||
kube::version::ldflag() {
|
||||
local key=${1}
|
||||
local val=${2}
|
||||
|
||||
GO_VERSION=($(go version))
|
||||
|
||||
if [[ -n $(echo "${GO_VERSION[2]}" | grep -E 'go1.1|go1.2|go1.3|go1.4') ]]; then
|
||||
echo "-X ${KUBE_GO_PACKAGE}/pkg/version.${key} ${val}"
|
||||
else
|
||||
echo "-X ${KUBE_GO_PACKAGE}/pkg/version.${key}=${val}"
|
||||
fi
|
||||
echo "-X ${KUBE_GO_PACKAGE}/pkg/version.${key}=${val}"
|
||||
}
|
||||
|
||||
# Prints the value that needs to be passed to the -ldflags parameter of go build
|
||||
|
|
|
@ -46,7 +46,6 @@ kube::test::find_dirs() {
|
|||
)
|
||||
}
|
||||
|
||||
# -covermode=atomic becomes default with -race in Go >=1.3
|
||||
KUBE_TIMEOUT=${KUBE_TIMEOUT:--timeout 120s}
|
||||
KUBE_COVER=${KUBE_COVER:-n} # set to 'y' to enable coverage collection
|
||||
KUBE_COVERMODE=${KUBE_COVERMODE:-atomic}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This script installs std -race on Travis (see https://code.google.com/p/go/issues/detail?id=6479)
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
if [[ "${TRAVIS}" == "true" ]]; then
|
||||
GO_VERSION=($(go version))
|
||||
|
||||
if [[ ${GO_VERSION[2]} < "go1.3" ]]; then
|
||||
echo "Installing the -race compatible version of the std go library"
|
||||
go install -a -race std
|
||||
fi
|
||||
fi
|
|
@ -21,13 +21,9 @@ set -o nounset
|
|||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
|
||||
GO_VERSION=($(go version))
|
||||
|
||||
if [[ -n $(echo "${GO_VERSION[2]}" | grep -E 'go1.1|go1.2|go1.3') ]]; then
|
||||
echo "Unsupported go version '${GO_VERSION}', skipping gofmt."
|
||||
exit 0
|
||||
fi
|
||||
kube::golang::verify_go_version
|
||||
|
||||
cd "${KUBE_ROOT}"
|
||||
|
||||
|
|
|
@ -21,13 +21,9 @@ set -o nounset
|
|||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
|
||||
GO_VERSION=($(go version))
|
||||
|
||||
if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.4|go1.6') ]]; then
|
||||
echo "Unsupported go version '${GO_VERSION[2]}', skipping gofmt."
|
||||
exit 1
|
||||
fi
|
||||
kube::golang::verify_go_version
|
||||
|
||||
cd "${KUBE_ROOT}"
|
||||
|
||||
|
|
|
@ -1739,10 +1739,7 @@ func appendAllLabels(showLabels bool, itemLabels map[string]string) string {
|
|||
func appendLabelTabs(columnLabels []string) string {
|
||||
var buffer bytes.Buffer
|
||||
|
||||
for i := range columnLabels {
|
||||
// NB: This odd dance is to make the loop both compatible with go 1.3 and
|
||||
// pass `gofmt -s`
|
||||
_ = i
|
||||
for range columnLabels {
|
||||
buffer.WriteString("\t")
|
||||
}
|
||||
buffer.WriteString("\n")
|
||||
|
|
|
@ -22,8 +22,7 @@ import (
|
|||
"path/filepath"
|
||||
)
|
||||
|
||||
//IoUtil is a util for common IO operations
|
||||
//it also backports certain operations from golang 1.5
|
||||
// IoUtil is a mockable util for common IO operations
|
||||
type IoUtil interface {
|
||||
ReadDir(dirname string) ([]os.FileInfo, error)
|
||||
Lstat(name string) (os.FileInfo, error)
|
||||
|
|
Loading…
Reference in New Issue