Skip to content

Commit

Permalink
Do not include bazel related deps in root go.mod
Browse files Browse the repository at this point in the history
- add ./hack/tools/go.mod, this makes ./hack/tools a distinct module
- hack/tools/tools.go undescore imports bazel related tools, over time we
can add others.
- hack/*.sh scripts will cd to hack/tools and go install tools from there

Signed-off-by: Davanum Srinivas <[email protected]>
  • Loading branch information
dims committed Apr 20, 2020
1 parent 32540b0 commit 12146cb
Show file tree
Hide file tree
Showing 145 changed files with 375 additions and 36,311 deletions.
440 changes: 0 additions & 440 deletions Godeps/LICENSES

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/root/.kazelcfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"SkippedPaths": [
"^_.*",
"/_",
"^hack/tools",
"^third_party/etcd.*"
],
"AddSourcesRules": true,
Expand Down
3 changes: 0 additions & 3 deletions build/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ limitations under the License.
package tools

import (
_ "github.com/bazelbuild/bazel-gazelle/cmd/gazelle"
_ "github.com/bazelbuild/buildtools/buildozer"
_ "github.com/cespare/prettybench"
_ "github.com/client9/misspell/cmd/misspell"
_ "github.com/go-bindata/go-bindata/go-bindata"
Expand All @@ -37,5 +35,4 @@ import (
_ "k8s.io/gengo/examples/import-boss/generators"
_ "k8s.io/gengo/examples/set-gen/generators"
_ "k8s.io/kube-openapi/cmd/openapi-gen"
_ "k8s.io/repo-infra/cmd/kazel"
)
76 changes: 2 additions & 74 deletions go.mod

Large diffs are not rendered by default.

76 changes: 0 additions & 76 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hack/make-rules/vet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if [[ ${#targets[@]} -eq 0 ]]; then
# Do not run on third_party directories or generated client code or build tools.
while IFS='' read -r line; do
targets+=("${line}")
done < <(go list -e ./... | grep -E -v "/(build|third_party|vendor|staging|clientset_generated)/")
done < <(go list -e ./... | grep -E -v "/(build|third_party|vendor|staging|clientset_generated|hack)/")
fi

go vet "${goflags[@]:+${goflags[@]}}" "${targets[@]}"
2 changes: 2 additions & 0 deletions hack/tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This directory contains a stub go module used to track version of development
tools like the ones needed for updating bazel BUILD files.
9 changes: 9 additions & 0 deletions hack/tools/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module k8s.io/kubernetes/hack/tools

go 1.13

require (
github.com/bazelbuild/bazel-gazelle v0.19.1-0.20191105222053-70208cbdc798
github.com/bazelbuild/buildtools v0.0.0-20190917191645-69366ca98f89
k8s.io/repo-infra v0.0.1-alpha.1
)
335 changes: 335 additions & 0 deletions hack/tools/go.sum

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright 2016 Google Inc. All Rights Reserved.
/*
Copyright 2019 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.
Expand All @@ -11,3 +12,15 @@ 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.
*/

// Package tools is used to track binary dependencies with go modules
// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
package tools

import (
// bazel-related tools
_ "github.com/bazelbuild/bazel-gazelle/cmd/gazelle"
_ "github.com/bazelbuild/buildtools/buildozer"
_ "k8s.io/repo-infra/cmd/kazel"
)
12 changes: 7 additions & 5 deletions hack/update-bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
export GOBIN="${KUBE_OUTPUT_BINPATH}"
PATH="${GOBIN}:${PATH}"

# Install tools we need, but only from vendor/...
pushd "${KUBE_ROOT}" >/dev/null
GO111MODULE=on GOFLAGS=-mod=vendor go install github.com/bazelbuild/bazel-gazelle/cmd/gazelle
GO111MODULE=on GOFLAGS=-mod=vendor go install github.com/bazelbuild/buildtools/buildozer
GO111MODULE=on GOFLAGS=-mod=vendor go install k8s.io/repo-infra/cmd/kazel
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
GO111MODULE=on go install github.com/bazelbuild/bazel-gazelle/cmd/gazelle
GO111MODULE=on go install github.com/bazelbuild/buildtools/buildozer
GO111MODULE=on go install k8s.io/repo-infra/cmd/kazel
popd >/dev/null

# Find all of the staging repos.
Expand Down Expand Up @@ -104,3 +103,6 @@ buildozer -quiet 'set clinkopts select({"@io_bazel_rules_go//go/platform:linux":
if [[ $ret != 0 && $ret != 3 ]]; then
exit 1
fi

# Avoid bazel stuff in tools/ directory
rm hack/tools/BUILD
2 changes: 1 addition & 1 deletion hack/verify-staticcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ while IFS='' read -r line; do
all_packages+=("./$line")
done < <( hack/make-rules/helpers/cache_go_dirs.sh "${KUBE_ROOT}/_tmp/all_go_dirs" |
grep "^${FOCUS:-.}" |
grep -vE "(third_party|generated|clientset_generated|/_)" |
grep -vE "(third_party|generated|clientset_generated|hack|/_)" |
grep -vE "$ignore_pattern" )

failing_packages=()
Expand Down
3 changes: 3 additions & 0 deletions test/typecheck/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ var (
// edit/record.go doesn't compile without gopkg.in/yaml.v2
// in $GOSRC/$GOROOT (both typecheck and the shell script).
"pkg/kubectl/cmd/testdata/edit",
// Tools we use for maintaining the code base but not necessarily
// ship as part of the release
"hack/tools",
}
)

Expand Down
24 changes: 0 additions & 24 deletions vendor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,6 @@ filegroup(
"//vendor/github.com/aws/aws-sdk-go/service/elbv2:all-srcs",
"//vendor/github.com/aws/aws-sdk-go/service/kms:all-srcs",
"//vendor/github.com/aws/aws-sdk-go/service/sts:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/config:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/flag:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/internal/version:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/internal/wspace:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/label:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/language:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/merger:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/pathtools:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/repo:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/resolve:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/rule:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/walk:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/api_proto:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/build:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/build_proto:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/buildozer:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/edit:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/file:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/lang:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/tables:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/wspace:all-srcs",
"//vendor/github.com/beorn7/perks/quantile:all-srcs",
"//vendor/github.com/blang/semver:all-srcs",
"//vendor/github.com/caddyserver/caddy/caddyfile:all-srcs",
Expand Down Expand Up @@ -403,7 +381,6 @@ filegroup(
"//vendor/golang.org/x/tools/go/packages:all-srcs",
"//vendor/golang.org/x/tools/go/types/objectpath:all-srcs",
"//vendor/golang.org/x/tools/go/types/typeutil:all-srcs",
"//vendor/golang.org/x/tools/go/vcs:all-srcs",
"//vendor/golang.org/x/tools/imports:all-srcs",
"//vendor/golang.org/x/tools/internal/fastwalk:all-srcs",
"//vendor/golang.org/x/tools/internal/gopathwalk:all-srcs",
Expand Down Expand Up @@ -490,7 +467,6 @@ filegroup(
"//vendor/k8s.io/kube-openapi/pkg/handler:all-srcs",
"//vendor/k8s.io/kube-openapi/pkg/schemaconv:all-srcs",
"//vendor/k8s.io/kube-openapi/pkg/util:all-srcs",
"//vendor/k8s.io/repo-infra/cmd/kazel:all-srcs",
"//vendor/k8s.io/system-validators/validators:all-srcs",
"//vendor/k8s.io/utils/buffer:all-srcs",
"//vendor/k8s.io/utils/clock:all-srcs",
Expand Down
18 changes: 0 additions & 18 deletions vendor/github.com/bazelbuild/bazel-gazelle/AUTHORS

This file was deleted.

29 changes: 0 additions & 29 deletions vendor/github.com/bazelbuild/bazel-gazelle/CONTRIBUTORS

This file was deleted.

Loading

0 comments on commit 12146cb

Please sign in to comment.