mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Less GOPATH dependence.
This commit is contained in:
@@ -38,6 +38,11 @@ function runUnitTests {
|
||||
make unit-test-all
|
||||
}
|
||||
|
||||
function onLinuxAndNotOnTravis {
|
||||
[[ ("linux" == "$(go env GOOS)") && (-z ${TRAVIS+x}) ]] && return
|
||||
false
|
||||
}
|
||||
|
||||
function testExamplesAgainstLatestKustomizeRelease {
|
||||
removeBin kustomize
|
||||
|
||||
@@ -49,7 +54,7 @@ function testExamplesAgainstLatestKustomizeRelease {
|
||||
--label testAgainstLatestRelease examples
|
||||
|
||||
# TODO: make work for non-linux
|
||||
if [[ (-z ${TRAVIS+x}) && ("linux" == "$(go env GOOS)") ]]; then
|
||||
if onLinuxAndNotOnTravis; then
|
||||
echo "On linux, and not on travis, so running the notravis example tests."
|
||||
|
||||
# Requires helm.
|
||||
@@ -74,53 +79,14 @@ function testExamplesAgainstLocalHead {
|
||||
echo "Example tests passed against HEAD"
|
||||
}
|
||||
|
||||
# This script tries to work for both travis
|
||||
# and contributors who have or do not have
|
||||
# GOPATH set.
|
||||
#
|
||||
# Use GOPATH to define XDG_CONFIG_HOME, then unset
|
||||
# GOPATH so that go.mod is unambiguously honored.
|
||||
#
|
||||
function unsetGoPath {
|
||||
local preferredGoPath=$GOPATH
|
||||
if [ -z ${GOPATH+x} ]; then
|
||||
# GOPATH is unset
|
||||
local tmp=$HOME/gopath
|
||||
if [ -d "$tmp" ]; then
|
||||
preferredGoPath=$tmp
|
||||
else
|
||||
# this works even if GOPATH undefined.
|
||||
preferredGoPath=$(go env GOPATH)
|
||||
fi
|
||||
else
|
||||
unset GOPATH
|
||||
fi
|
||||
# Having this set might contradict the Makefile,
|
||||
# so assure it's unset.
|
||||
unset GOPATH
|
||||
|
||||
if [ -z ${GOPATH+x} ]; then
|
||||
echo GOPATH is unset
|
||||
else
|
||||
echo "GOPATH=$GOPATH, but should be unset at this point."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# This is needed for plugins.
|
||||
# TODO: switch this to set KUSTOMIZE_PLUGIN_HOME instead.
|
||||
export XDG_CONFIG_HOME=$preferredGoPath/src/sigs.k8s.io
|
||||
echo "XDG_CONFIG_HOME=$XDG_CONFIG_HOME"
|
||||
if [ ! -d "$XDG_CONFIG_HOME" ]; then
|
||||
echo "$XDG_CONFIG_HOME is not a directory."
|
||||
echo "Unable to compile or otherwise work with kustomize plugins."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
unsetGoPath
|
||||
|
||||
|
||||
# With GOPATH now undefined, this most
|
||||
# likely this puts $HOME/go/bin on the path.
|
||||
# Regardless, subsequent go tool installs will
|
||||
# be placing binaries in this location.
|
||||
# With GOPATH now undefined, this most likely
|
||||
# puts $HOME/go/bin on the path. Regardless,
|
||||
# subsequent go tool installs will be placing
|
||||
# binaries in this location.
|
||||
PATH=$(go env GOPATH)/bin:$PATH
|
||||
|
||||
# Make sure we run in the root of the repo and
|
||||
|
||||
Reference in New Issue
Block a user