From b43afba89a750dc01431a91df7e6c457ffe54815 Mon Sep 17 00:00:00 2001 From: justinsb Date: Thu, 7 Oct 2021 08:22:20 -0400 Subject: [PATCH] Replace bazel :gofmt target with direct invocation The rule to run from the workspace is broken by the .bazel-bin change, but bazel now supports direct invocation. --- BUILD.bazel | 7 ------- Makefile | 2 +- hack/verify-gofmt.sh | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index cfdba4287f..b54ac75ea4 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -23,10 +23,3 @@ go_library( ], importpath = "k8s.io/kops", ) - -load("@io_k8s_repo_infra//defs:run_in_workspace.bzl", "workspace_binary") - -workspace_binary( - name = "gofmt", - cmd = "@go_sdk//:bin/gofmt", -) diff --git a/Makefile b/Makefile index a36ebe8d32..f79539c9b9 100644 --- a/Makefile +++ b/Makefile @@ -360,7 +360,7 @@ gomod: bazelisk gomod-prereqs .PHONY: gofmt gofmt: - find $(KOPS_ROOT) -name "*.go" | grep -v vendor | xargs ${BAZEL} run //:gofmt -- -w -s + find $(KOPS_ROOT) -name "*.go" | grep -v vendor | xargs ${BAZEL} run @go_sdk//:bin/gofmt -- -w -s .PHONY: goimports goimports: diff --git a/hack/verify-gofmt.sh b/hack/verify-gofmt.sh index ea86e46a68..2086e94ef0 100755 --- a/hack/verify-gofmt.sh +++ b/hack/verify-gofmt.sh @@ -18,7 +18,7 @@ cd "${KOPS_ROOT}" || exit 1 -bad_files=$(git ls-files "*.go" | grep -v vendor | xargs bazelisk run //:gofmt -- -s -w -l) +bad_files=$(git ls-files "*.go" | grep -v vendor | xargs bazelisk run @go_sdk//:bin/gofmt -- -s -w -l) if [[ -n "${bad_files}" ]]; then echo "FAIL: 'make gofmt' needs to be run on the following files: " echo "${bad_files}"