mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
Merge pull request #1076 from filbranden/config_environment1
More config-go.sh cleanup
This commit is contained in:
commit
b864c2ce3d
@ -97,25 +97,41 @@ kube::setup_go_environment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
KUBE_REPO_ROOT=$(dirname "${BASH_SOURCE:-$0}")/..
|
# --- Environment Variables ---
|
||||||
if [[ "${OSTYPE:-}" == *darwin* ]]; then
|
|
||||||
# Make the path absolute if it is not.
|
# KUBE_REPO_ROOT - Path to the top of the build tree.
|
||||||
if [[ "${KUBE_REPO_ROOT}" != /* ]]; then
|
# KUBE_TARGET - Path where output Go files are saved.
|
||||||
KUBE_REPO_ROOT=${PWD}/${KUBE_REPO_ROOT}
|
# KUBE_GO_PACKAGE - Full name of the Kubernetes Go package.
|
||||||
fi
|
|
||||||
else
|
# Make ${KUBE_REPO_ROOT} an absolute path.
|
||||||
# Resolve symlinks.
|
KUBE_REPO_ROOT=$(
|
||||||
KUBE_REPO_ROOT=$(readlink -f "${KUBE_REPO_ROOT}")
|
set -eu
|
||||||
fi
|
unset CDPATH
|
||||||
|
scripts_dir=$(dirname "${BASH_SOURCE[0]}")
|
||||||
|
cd "${scripts_dir}"
|
||||||
|
cd ..
|
||||||
|
pwd
|
||||||
|
)
|
||||||
|
export KUBE_REPO_ROOT
|
||||||
|
|
||||||
KUBE_TARGET="${KUBE_REPO_ROOT}/output/go"
|
KUBE_TARGET="${KUBE_REPO_ROOT}/output/go"
|
||||||
mkdir -p "${KUBE_TARGET}"
|
mkdir -p "${KUBE_TARGET}"
|
||||||
|
export KUBE_TARGET
|
||||||
|
|
||||||
KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes
|
KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes
|
||||||
KUBE_GO_PACKAGE_DIR="${KUBE_TARGET}/src/${KUBE_GO_PACKAGE}"
|
export KUBE_GO_PACKAGE
|
||||||
|
|
||||||
KUBE_GO_PACKAGE_BASEDIR=$(dirname "${KUBE_GO_PACKAGE_DIR}")
|
(
|
||||||
mkdir -p "${KUBE_GO_PACKAGE_BASEDIR}"
|
# Create symlink named ${KUBE_GO_PACKAGE} under output/go/src.
|
||||||
|
# So that Go knows how to import Kubernetes sources by full path.
|
||||||
|
# Use a subshell to avoid leaking these variables.
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
go_pkg_dir="${KUBE_TARGET}/src/${KUBE_GO_PACKAGE}"
|
||||||
|
go_pkg_basedir=$(dirname "${go_pkg_dir}")
|
||||||
|
mkdir -p "${go_pkg_basedir}"
|
||||||
|
rm -f "${go_pkg_dir}"
|
||||||
|
# TODO: This symlink should be relative.
|
||||||
|
ln -s "${KUBE_REPO_ROOT}" "${go_pkg_dir}"
|
||||||
|
)
|
||||||
|
|
||||||
# Create symlink under output/go/src.
|
|
||||||
ln -snf "${KUBE_REPO_ROOT}" "${KUBE_GO_PACKAGE_DIR}"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user