Source gofmt from bazel go

Using the approach from k8s.io/repo-infra.  This avoids problems where
we are testing with a different version of go than we are building
with.
This commit is contained in:
Justin SB 2019-04-21 16:41:11 -04:00
parent de581b1b64
commit bf4c4a1a95
No known key found for this signature in database
GPG Key ID: 8DEC5C8217494E37
4 changed files with 17 additions and 16 deletions

View File

@ -21,3 +21,10 @@ 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

@ -500,20 +500,7 @@ dep-ensure: dep-prereqs
.PHONY: gofmt
gofmt:
gofmt -w -s channels/
gofmt -w -s cloudmock/
gofmt -w -s cmd/
gofmt -w -s examples/
gofmt -w -s nodeup/
gofmt -w -s util/
gofmt -w -s upup/pkg/
gofmt -w -s pkg/
gofmt -w -s tests/
gofmt -w -s protokube/cmd
gofmt -w -s protokube/pkg
gofmt -w -s protokube/tests
gofmt -w -s dns-controller/cmd
gofmt -w -s dns-controller/pkg
find -name "*.go" | grep -v vendor | xargs bazel run //:gofmt -- -w -s
.PHONY: goimports
goimports:

View File

@ -113,3 +113,10 @@ http_file(
urls = ["https://kubeupv2.s3.amazonaws.com/kops/1.11.1/linux/amd64/utils.tar.gz"],
sha256 = "0e685eb751a32f782705311049b2592c4724add6f19ffdad1e7ce4f55816d7d8",
)
git_repository(
name = "io_k8s_repo_infra",
commit = "4ce715fbe67d8fbed05ec2bb47a148e754100a4b",
remote = "https://github.com/kubernetes/repo-infra.git",
shallow_since = "1517262872 -0800",
)

View File

@ -16,9 +16,9 @@
. $(dirname "${BASH_SOURCE}")/common.sh
GOFMT="gofmt -s -w"
GOFMT="bazel run //:gofmt -- -s -w"
bad_files=$(git ls-files "*.go" | grep -v vendor | xargs -I {} $GOFMT -l {})
bad_files=$(git ls-files "*.go" | grep -v vendor | xargs $GOFMT -l)
if [[ -n "${bad_files}" ]]; then
echo "FAIL: '$GOFMT' needs to be run on the following files: "
echo "${bad_files}"