From 105e8f8467d6ab0ac614bc8ce36cdf2d8754f5d9 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Thu, 21 Jan 2021 16:27:45 -0800 Subject: [PATCH] Rename *-hack-tools.sh -> *-internal-modules.sh Prep to add more such modules --- ...ck-tools.sh => update-internal-modules.sh} | 20 +++++++++++++------ ...ck-tools.sh => verify-internal-modules.sh} | 18 +++++++++-------- 2 files changed, 24 insertions(+), 14 deletions(-) rename hack/{update-hack-tools.sh => update-internal-modules.sh} (71%) rename hack/{verify-hack-tools.sh => verify-internal-modules.sh} (67%) diff --git a/hack/update-hack-tools.sh b/hack/update-internal-modules.sh similarity index 71% rename from hack/update-hack-tools.sh rename to hack/update-internal-modules.sh index 9390a324db8..6f2e91090e3 100755 --- a/hack/update-hack-tools.sh +++ b/hack/update-internal-modules.sh @@ -21,19 +21,27 @@ set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" +# These are "internal" modules. For various reasons, we want them to be +# decoupled from their parent modules. +MODULES=( + hack/tools +) + # Explicitly opt into go modules, even though we're inside a GOPATH directory export GO111MODULE=on # Detect problematic GOPROXY settings that prevent lookup of dependencies if [[ "${GOPROXY:-}" == "off" ]]; then - kube::log::error "Cannot run hack/update-hack-tools.sh with \$GOPROXY=off" + kube::log::error "Cannot run hack/update-internal-modules.sh with \$GOPROXY=off" exit 1 fi kube::golang::verify_go_version -pushd "${KUBE_ROOT}/hack/tools" >/dev/null - echo "=== tidying go.mod/go.sum in hack/tools" - go mod edit -fmt - go mod tidy -popd >/dev/null +for mod in "${MODULES[@]}"; do + pushd "${KUBE_ROOT}/${mod}" >/dev/null + echo "=== tidying go.mod/go.sum in ${mod}" + go mod edit -fmt + go mod tidy + popd >/dev/null +done diff --git a/hack/verify-hack-tools.sh b/hack/verify-internal-modules.sh similarity index 67% rename from hack/verify-hack-tools.sh rename to hack/verify-internal-modules.sh index c70436023ff..8ec9678e17f 100755 --- a/hack/verify-hack-tools.sh +++ b/hack/verify-internal-modules.sh @@ -21,24 +21,26 @@ set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" -_tmpdir="$(kube::realpath "$(mktemp -d -t verify-hack-tools.XXXXXX)")" -kube::util::trap_add "rm -rf ${_tmpdir}" EXIT +kube::util::ensure_clean_working_dir + +_tmpdir="$(kube::realpath "$(mktemp -d -t verify-internal-modules.XXXXXX)")" +#kube::util::trap_add "rm -rf ${_tmpdir}" EXIT _tmp_gopath="${_tmpdir}/go" _tmp_kuberoot="${_tmp_gopath}/src/k8s.io/kubernetes" -_tmp_hack="${_tmp_gopath}/src/k8s.io/kubernetes/hack" -mkdir -p "${_tmp_hack}/.." -cp -a "${KUBE_ROOT}/hack" "${_tmp_hack}/.." +git worktree add -f "${_tmp_kuberoot}" HEAD +kube::util::trap_add "git worktree remove -f ${_tmp_kuberoot}" EXIT pushd "${_tmp_kuberoot}" >/dev/null -./hack/update-hack-tools.sh +./hack/update-internal-modules.sh popd -diff=$(diff -Naupr "${KUBE_ROOT}/hack" "${_tmp_kuberoot}/hack" || true) +git -C "${_tmp_kuberoot}" add -N . +diff=$(git -C "${_tmp_kuberoot}" diff HEAD || true) if [[ -n "${diff}" ]]; then echo "${diff}" >&2 echo >&2 - echo "Run ./hack/update-hack-tools.sh" >&2 + echo "Run ./hack/update-internal-modules.sh" >&2 exit 1 fi