Rename *-hack-tools.sh -> *-internal-modules.sh

Prep to add more such modules
This commit is contained in:
Tim Hockin 2021-01-21 16:27:45 -08:00
parent 3aa319c894
commit 105e8f8467
2 changed files with 24 additions and 14 deletions

View File

@ -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

View File

@ -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