Skip to content

Commit

Permalink
Update hack/update-deps.sh to use go modules
Browse files Browse the repository at this point in the history
  • Loading branch information
fejta committed Jan 17, 2019
1 parent 0526d60 commit 2a67214
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
22 changes: 20 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
load("@io_kubernetes_build//defs:run_in_workspace.bzl", "workspace_binary")

workspace_binary(
name = "dep",
cmd = "//vendor/github.com/golang/dep/cmd/dep",
name = "go",
cmd = "@go_sdk//:bin/go",
)

workspace_binary(
name = "update-minor",
args = [
"get",
"-u",
],
cmd = "@go_sdk//:bin/go",
)

workspace_binary(
name = "update-patch",
args = [
"get",
"-u=patch",
],
cmd = "@go_sdk//:bin/go",
)

workspace_binary(
Expand Down
1 change: 1 addition & 0 deletions hack/update-bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set -o pipefail

cd "$(git rev-parse --show-toplevel)"
mkdir -p ./vendor
find vendor -name BUILD -o -name BUILD.bazel -exec rm '{}' +
touch ./vendor/BUILD.bazel
bazel run //:gazelle
bazel run //:kazel
34 changes: 19 additions & 15 deletions hack/update-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,24 @@ set -o xtrace
cd "$(git rev-parse --show-toplevel)"
trap 'echo "FAILED" >&2' ERR

# dep itself has a problematic testdata directory with infinite symlinks which
# makes bazel sad: https://github.com/golang/dep/pull/1412
# dep should probably be removing it, but it doesn't:
# https://github.com/golang/dep/issues/1580
rm -rf vendor/github.com/golang/dep/internal/fs/testdata
# go-bindata does too, and is not maintained ...
rm -rf vendor/github.com/jteeuwen/go-bindata/testdata
# docker has a contrib dir with nothing we use in it, dep will retain the licenses
# which includes some GPL, so we manually prune this.
# See https://github.com/kubernetes/steering/issues/57
rm -rf vendor/github.com/docker/docker/contrib
bazel run //:dep -- ensure -v "$@"
rm -rf vendor/github.com/golang/dep/internal/fs/testdata
rm -rf vendor/github.com/jteeuwen/go-bindata/testdata
rm -rf vendor/github.com/docker/docker/contrib
prune-vendor() {
find vendor -type f \
-not -iname "*.go" \
-not -iname "*.proto" \
-not -iname "*.s" \
-not -iname "*.h" \
-not -iname "*.c" \
-not -iname "AUTHORS*" \
-not -iname "CONTRIBUTORS*" \
-not -iname "LICENSE*" \
-exec rm '{}' \;
}

rm -rf vendor
export GO111MODULE=on
bazel run //:go -- mod tidy
bazel run //:go -- mod vendor
prune-vendor
hack/update-bazel.sh
bazel run //:gazelle -- update-repos --from_file=go.mod
echo SUCCESS
2 changes: 0 additions & 2 deletions hack/verify-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ mkdir -p "${_tmp_repo_root}/.."
cp -a "${repo_root}" "${_tmp_repo_root}/.."

cd "${_tmp_repo_root}"
export GOPATH="${_tmp_gopath}"
export PATH="${_tmp_gopath}/bin:${PATH}"
echo $GOPATH
./hack/update-deps.sh

diff=$(diff -Nupr \
Expand Down

0 comments on commit 2a67214

Please sign in to comment.