Change pushd $d; go ...; popd to go -C $d ...

Just an annoyance in reading these scripts.
This commit is contained in:
Tim Hockin 2024-03-02 14:27:33 -08:00
parent 1fceb815ac
commit a0215badb8
No known key found for this signature in database
10 changed files with 22 additions and 46 deletions

View File

@ -48,10 +48,8 @@ export PATH=${GOPATH}/bin:${PWD}/third_party/etcd:/usr/local/go/bin:${PATH}
export GO111MODULE=off export GO111MODULE=off
# Install tools we need # Install tools we need
pushd "${KUBE_ROOT}/hack/tools" >/dev/null GO111MODULE=on go -C "${KUBE_ROOT}/hack/tools" install github.com/cespare/prettybench
GO111MODULE=on go install github.com/cespare/prettybench GO111MODULE=on go -C "${KUBE_ROOT}/hack/tools" install gotest.tools/gotestsum
GO111MODULE=on go install gotest.tools/gotestsum
popd >/dev/null
# Disable the Go race detector. # Disable the Go race detector.
export KUBE_RACE=" " export KUBE_RACE=" "

View File

@ -32,9 +32,7 @@ export PATH=${GOPATH}/bin:${PWD}/third_party/etcd:/usr/local/go/bin:${PATH}
export GO111MODULE=off export GO111MODULE=off
# Install tools we need # Install tools we need
pushd "./hack/tools" >/dev/null GO111MODULE=on go -C "./hack/tools" install gotest.tools/gotestsum
GO111MODULE=on go install gotest.tools/gotestsum
popd >/dev/null
# Disable coverage report # Disable coverage report
export KUBE_COVER="n" export KUBE_COVER="n"

View File

@ -599,11 +599,7 @@ kube::golang::setup_gomaxprocs() {
# when running in a container, please see https://github.com/golang/go/issues/33803 # when running in a container, please see https://github.com/golang/go/issues/33803
if [[ -z "${GOMAXPROCS:-}" ]]; then if [[ -z "${GOMAXPROCS:-}" ]]; then
if ! command -v ncpu >/dev/null 2>&1; then if ! command -v ncpu >/dev/null 2>&1; then
# shellcheck disable=SC2164 go -C "${KUBE_ROOT}/hack/tools" install ./ncpu || echo "Will not automatically set GOMAXPROCS"
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
go install ./ncpu || echo "Will not automatically set GOMAXPROCS"
# shellcheck disable=SC2164
popd >/dev/null
fi fi
if command -v ncpu >/dev/null 2>&1; then if command -v ncpu >/dev/null 2>&1; then
GOMAXPROCS=$(ncpu) GOMAXPROCS=$(ncpu)

View File

@ -190,10 +190,8 @@ produceJUnitXMLReport() {
junit_xml_filename="${junit_filename_prefix}.xml" junit_xml_filename="${junit_filename_prefix}.xml"
if ! command -v gotestsum >/dev/null 2>&1; then if ! command -v gotestsum >/dev/null 2>&1; then
kube::log::status "gotestsum not found; installing from hack/tools" kube::log::status "gotestsum not found; installing from ./hack/tools"
pushd "${KUBE_ROOT}/hack/tools" >/dev/null go -C "${KUBE_ROOT}/hack/tools" install gotest.tools/gotestsum
go install gotest.tools/gotestsum
popd >/dev/null
fi fi
gotestsum --junitfile "${junit_xml_filename}" --raw-command cat "${junit_filename_prefix}"*.stdout gotestsum --junitfile "${junit_xml_filename}" --raw-command cat "${junit_filename_prefix}"*.stdout
if [[ ! ${KUBE_KEEP_VERBOSE_TEST_OUTPUT} =~ ^[yY]$ ]]; then if [[ ! ${KUBE_KEEP_VERBOSE_TEST_OUTPUT} =~ ^[yY]$ ]]; then
@ -201,10 +199,8 @@ produceJUnitXMLReport() {
fi fi
if ! command -v prune-junit-xml >/dev/null 2>&1; then if ! command -v prune-junit-xml >/dev/null 2>&1; then
kube::log::status "prune-junit-xml not found; installing from hack/tools" kube::log::status "prune-junit-xml not found; installing from ./cmd"
pushd "${KUBE_ROOT}/cmd/prune-junit-xml" >/dev/null go -C "${KUBE_ROOT}/cmd/prune-junit-xml" install .
go install .
popd >/dev/null
fi fi
prune-junit-xml "${junit_xml_filename}" prune-junit-xml "${junit_xml_filename}"

View File

@ -38,9 +38,7 @@ fi
kube::golang::setup_env kube::golang::setup_env
for mod in "${MODULES[@]}"; do for mod in "${MODULES[@]}"; do
pushd "${KUBE_ROOT}/${mod}" >/dev/null echo "=== tidying go.mod/go.sum in ${mod}"
echo "=== tidying go.mod/go.sum in ${mod}" go -C "${KUBE_ROOT}/${mod}" mod edit -fmt
go mod edit -fmt go -C "${KUBE_ROOT}/${mod}" mod tidy
go mod tidy
popd >/dev/null
done done

View File

@ -27,9 +27,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env kube::golang::setup_env
echo 'installing mockgen' echo 'installing mockgen'
pushd "${KUBE_ROOT}/hack/tools" >/dev/null go -C "${KUBE_ROOT}/hack/tools" install github.com/golang/mock/mockgen
go install github.com/golang/mock/mockgen
popd >/dev/null
function git_grep() { function git_grep() {
git grep --untracked --exclude-standard \ git grep --untracked --exclude-standard \

View File

@ -36,9 +36,7 @@ PATH="${GOBIN}:${PATH}"
# Install golangci-lint # Install golangci-lint
echo 'installing net parser converter' echo 'installing net parser converter'
pushd "${KUBE_ROOT}/hack/tools" >/dev/null go -C "${KUBE_ROOT}/hack/tools" install github.com/aojea/sloppy-netparser
go install github.com/aojea/sloppy-netparser
popd >/dev/null
cd "${KUBE_ROOT}" cd "${KUBE_ROOT}"

View File

@ -26,9 +26,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::verify_go_version kube::golang::verify_go_version
pushd "${KUBE_ROOT}/hack/tools" >/dev/null go -C "${KUBE_ROOT}/hack/tools" install github.com/jcchavezs/porto/cmd/porto
go install github.com/jcchavezs/porto/cmd/porto
popd >/dev/null
porto --restrict-to-dirs="staging" --restrict-to-files="doc\\.go$" -w "${KUBE_ROOT}" porto --restrict-to-dirs="staging" --restrict-to-files="doc\\.go$" -w "${KUBE_ROOT}"

View File

@ -127,15 +127,13 @@ done
# Install golangci-lint # Install golangci-lint
echo "installing golangci-lint and logcheck plugin from hack/tools into ${GOBIN}" echo "installing golangci-lint and logcheck plugin from hack/tools into ${GOBIN}"
pushd "${KUBE_ROOT}/hack/tools" >/dev/null go -C "${KUBE_ROOT}/hack/tools" install github.com/golangci/golangci-lint/cmd/golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint if [ "${golangci_config}" ]; then
if [ "${golangci_config}" ]; then # This cannot be used without a config.
# This cannot be used without a config. # This uses `go build` because `go install -buildmode=plugin` doesn't work
# This uses `go build` because `go install -buildmode=plugin` doesn't work # (on purpose: https://github.com/golang/go/issues/64964).
# (on purpose: https://github.com/golang/go/issues/64964). go -C "${KUBE_ROOT}/hack/tools" build -o "${GOBIN}/logcheck.so" -buildmode=plugin sigs.k8s.io/logtools/logcheck/plugin
go build -o "${GOBIN}/logcheck.so" -buildmode=plugin sigs.k8s.io/logtools/logcheck/plugin fi
fi
popd >/dev/null
if [ "${golangci_config}" ]; then if [ "${golangci_config}" ]; then
# The relative path to _output/local/bin only works if that actually is the # The relative path to _output/local/bin only works if that actually is the

View File

@ -32,9 +32,7 @@ export GOBIN="${KUBE_OUTPUT_BIN}"
PATH="${GOBIN}:${PATH}" PATH="${GOBIN}:${PATH}"
# Install tools we need # Install tools we need
pushd "${KUBE_ROOT}/hack/tools" >/dev/null go -C "${KUBE_ROOT}/hack/tools" install github.com/client9/misspell/cmd/misspell
go install github.com/client9/misspell/cmd/misspell
popd >/dev/null
# Spell checking # Spell checking
# All the skipping files are defined in hack/.spelling_failures # All the skipping files are defined in hack/.spelling_failures