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.
This commit is contained in:
justinsb 2021-10-07 08:22:20 -04:00
parent 05ae9aa5b4
commit b43afba89a
3 changed files with 2 additions and 9 deletions

7
BUILD.bazel generated
View File

@ -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",
)

View File

@ -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:

View File

@ -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}"