From d8988801c21a992faa952b7385efa5f518a68546 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Sat, 1 Oct 2022 14:11:26 -0700 Subject: [PATCH] Remove old make-helper script --- hack/make-rules/helpers/cache_go_dirs.sh | 79 ------------------------ hack/update-codegen.sh | 42 ++++++++++++- 2 files changed, 40 insertions(+), 81 deletions(-) delete mode 100755 hack/make-rules/helpers/cache_go_dirs.sh diff --git a/hack/make-rules/helpers/cache_go_dirs.sh b/hack/make-rules/helpers/cache_go_dirs.sh deleted file mode 100755 index cfd4fa25af1..00000000000 --- a/hack/make-rules/helpers/cache_go_dirs.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2014 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This script finds, caches, and prints a list of all directories that hold -# *.go files. If any directory is newer than the cache, re-find everything and -# update the cache. Otherwise use the cached file. - -set -o errexit -set -o nounset -set -o pipefail - -if [[ -z "${1:-}" ]]; then - echo "usage: $0 " - exit 1 -fi -CACHE="$1"; shift - -trap 'rm -f "${CACHE}"' HUP INT TERM ERR - -# This is a partial 'find' command. The caller is expected to pass the -# remaining arguments. -# -# Example: -# kfind -type f -name foobar.go -function kfind() { - # We want to include the "special" vendor directories which are actually - # part of the Kubernetes source tree (./staging/*) but we need them to be - # named as their ./vendor/* equivalents. Also, we do not want all of - # ./vendor nor ./hack/tools/vendor nor even all of ./vendor/k8s.io. - find -H . \ - \( \ - -not \( \ - \( \ - -name '_*' -o \ - -name '.[^.]*' -o \ - \( \ - -name 'vendor' \ - -type d \ - \) -o \ - \( \ - -name 'testdata' \ - -type d \ - \) \ - \) -prune \ - \) \ - \) \ - "$@" \ - | sed 's|^./staging/src|vendor|' -} - -# It's *significantly* faster to check whether any directories are newer than -# the cache than to blindly rebuild it. -if [[ -f "${CACHE}" && -n "${CACHE}" ]]; then - N=$(kfind -type d -newer "${CACHE}" -print -quit | wc -l) - if [[ "${N}" == 0 ]]; then - cat "${CACHE}" - exit - fi -fi - -mkdir -p "$(dirname "${CACHE}")" -kfind -type f -name \*.go \ - | sed 's|/[^/]*$||' \ - | sed 's|^./||' \ - | LC_ALL=C sort -u \ - | tee "${CACHE}" diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index c96381181e7..4e606d95550 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -24,6 +24,7 @@ KUBE_VERBOSE="${KUBE_VERBOSE:-1}" KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" +cd "${KUBE_ROOT}" kube::golang::setup_env @@ -41,6 +42,44 @@ if [[ "${DBG_CODEGEN}" == 1 ]]; then kube::log::status "DBG: starting generated_files" fi +# This is a partial 'find' command. The caller is expected to pass the +# remaining arguments. +# +# Example: +# kfind -type f -name foobar.go +function kfind() { + # We want to include the "special" vendor directories which are actually + # part of the Kubernetes source tree (./staging/*) but we need them to be + # named as their ./vendor/* equivalents. Also, we do not want all of + # ./vendor nor ./hack/tools/vendor nor even all of ./vendor/k8s.io. + find -H . \ + \( \ + -not \( \ + \( \ + -name '_*' -o \ + -name '.[^.]*' -o \ + \( \ + -name 'vendor' \ + -type d \ + \) -o \ + \( \ + -name 'testdata' \ + -type d \ + \) \ + \) -prune \ + \) \ + \) \ + "$@" \ + | sed 's|^./staging/src|vendor|' +} + +function find_all_go_dirs() { + kfind -type f -name \*.go \ + | sed 's|/[^/]*$||' \ + | sed 's|^./||' \ + | LC_ALL=C sort -u +} + # This variable holds a list of every directory that contains Go files in this # project. Other rules and variables can use this as a starting point to # reduce filesystem accesses. @@ -48,8 +87,7 @@ if [[ "${DBG_CODEGEN}" == 1 ]]; then kube::log::status "DBG: finding all *.go dirs" fi ALL_GO_DIRS=() -kube::util::read-array ALL_GO_DIRS < \ - <(hack/make-rules/helpers/cache_go_dirs.sh .make/all_go_dirs) +kube::util::read-array ALL_GO_DIRS < <(find_all_go_dirs) if [[ "${DBG_CODEGEN}" == 1 ]]; then kube::log::status "DBG: found ${#ALL_GO_DIRS[@]} *.go dirs" fi