From 90e6546c689d070fd31bb6f84de66f224e18b2f4 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Sat, 2 Mar 2024 14:34:48 -0800 Subject: [PATCH] Use go.work to auto-find internal modules --- hack/update-internal-modules.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hack/update-internal-modules.sh b/hack/update-internal-modules.sh index 2b29b9f1688..af2e330f7e7 100755 --- a/hack/update-internal-modules.sh +++ b/hack/update-internal-modules.sh @@ -23,11 +23,13 @@ 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 - staging/src/k8s.io/code-generator/examples - staging/src/k8s.io/kms/internal/plugins/_mock -) +MODULES=() +kube::util::read-array MODULES < <( + git ls-files -cmo --exclude-standard -- ':!:vendor/*' ':(glob)*/**/go.work' \ + | while read -r F; do \ + dirname "${F}"; \ + done + ) # Detect problematic GOPROXY settings that prevent lookup of dependencies if [[ "${GOPROXY:-}" == "off" ]]; then @@ -38,9 +40,7 @@ fi kube::golang::setup_env 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 + echo "=== tidying go.mod/go.sum in ${mod}" + go -C "${KUBE_ROOT}/${mod}" mod edit -fmt + go -C "${KUBE_ROOT}/${mod}" mod tidy done