Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #115377: Fetch go version using gimme if needed #115497

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSES/third_party/gimme/LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015-2018 gimme contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions build/common.sh
Expand Up @@ -526,6 +526,8 @@ function kube::build::run_build_command_ex() {
--env "KUBE_BUILD_WITH_COVERAGE=${KUBE_BUILD_WITH_COVERAGE:-}"
--env "KUBE_BUILD_PLATFORMS=${KUBE_BUILD_PLATFORMS:-}"
--env "KUBE_CGO_OVERRIDES=' ${KUBE_CGO_OVERRIDES[*]:-} '"
--env "FORCE_HOST_GO=${FORCE_HOST_GO:-}"
--env "GO_VERSION=${GO_VERSION:-}"
--env "GOFLAGS=${GOFLAGS:-}"
--env "GOGCFLAGS=${GOGCFLAGS:-}"
--env "SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-}"
Expand Down
1 change: 1 addition & 0 deletions hack/.spelling_failures
@@ -1,5 +1,6 @@
CHANGELOG
go.mod
go.sum
third_party/
translations/
vendor/
1 change: 0 additions & 1 deletion hack/jenkins/test-dockerized.sh
Expand Up @@ -48,7 +48,6 @@ export LOG_LEVEL=4
cd "${GOPATH}/src/k8s.io/kubernetes"

make generated_files
go install ./cmd/...
./hack/install-etcd.sh

make test-cmd
Expand Down
14 changes: 14 additions & 0 deletions hack/lib/golang.sh
Expand Up @@ -470,7 +470,21 @@ kube::golang::create_gopath_tree() {
}

# Ensure the go tool exists and is a viable version.
# Inputs:
# env-var GO_VERSION is the desired go version to use, downloading it if needed (defaults to content of .go-version)
# env-var FORCE_HOST_GO set to a non-empty value uses the go version in the $PATH and skips ensuring $GO_VERSION is used
kube::golang::verify_go_version() {
# default GO_VERSION to content of .go-version
GO_VERSION="${GO_VERSION:-"$(cat "${KUBE_ROOT}/.go-version")"}"
# only setup go if we haven't set FORCE_HOST_GO, or `go version` doesn't match GO_VERSION
if ! ([ -n "${FORCE_HOST_GO:-}" ] || \
(command -v go >/dev/null && [ "$(go version | cut -d' ' -f3)" = "go${GO_VERSION}" ])); then
export GIMME_ENV_PREFIX=${GIMME_ENV_PREFIX:-"${KUBE_OUTPUT}/.gimme/envs"}
export GIMME_VERSION_PREFIX=${GIMME_VERSION_PREFIX:-"${KUBE_OUTPUT}/.gimme/versions"}
# eval because the output of this is shell to set PATH etc.
eval "$("${KUBE_ROOT}/third_party/gimme/gimme" "${GO_VERSION}")"
fi

if [[ -z "$(command -v go)" ]]; then
kube::log::usage_from_stdin <<EOF
Can't find 'go' in PATH, please fix and retry.
Expand Down
21 changes: 21 additions & 0 deletions third_party/gimme/LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015-2018 gimme contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions third_party/gimme/README.md
@@ -0,0 +1,6 @@
# gimme

This is an unmodified copy of [gimme], so we don't have to download it
from the internet.

[gimme]: https://github.com/travis-ci/gimme