Skip to content

Commit

Permalink
Rename *-hack-tools.sh -> *-internal-modules.sh
Browse files Browse the repository at this point in the history
Prep to add more such modules
  • Loading branch information
thockin committed Jan 25, 2021
1 parent 3aa319c commit 105e8f8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
20 changes: 14 additions & 6 deletions hack/update-hack-tools.sh → hack/update-internal-modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 10 additions & 8 deletions hack/verify-hack-tools.sh → hack/verify-internal-modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 105e8f8

Please sign in to comment.