Skip to content

Commit

Permalink
vendor: add fake imports for glide's benefit
Browse files Browse the repository at this point in the history
We've repeatedly encountered issues arising from the fact that entries in `glide.yaml` are not treated as the, or even as additional, roots in the calulation of the transitive dependency closure.

Previously in #11797, we attempted to clarify the situation by pruning all derivable specs from `glide.yaml`, so that it would be clear where the dependency roots were indeed coming from.

We however left vendored tools, and their transitive dependencies, there, as they were not derivable from any imports (e.g. some are not importable due to `package main`).

As we've already found though, simply adding a tool to `glide.yaml`, or even `glide get`'ing them, doesn't work.

Thus, to reliably vendor tools and their dependencies, we need to introduce artifical imports of them. We get around the `package main` issue with by hiding the imports in a file that is build-tagged `+glide` so we never attempt to build it.

---

The `glide up` used to test this also picked up the following uninteresting changes:

- golang.org/x/tools: ae1141fc -> ae1141fc
  - golang/tools@ae1141f...3d92dd6
- github.com/cockroachdb/cockroach-go: 2c874f13 -> 140a8c58
  - cockroachdb/cockroach-go@2c874f1...140a8c5
- github.com/coreos/etcd: cfd10b4 -> b713113
  - etcd-io/etcd@cfd10b4...b713113
- github.com/docker/distribution: 67095fbc -> 844b9287
  - distribution/distribution@67095fb...844b928
- github.com/google/go-github: 171a9316 -> 43e7458c
  - google/go-github@171a931...43e7458
- github.com/opencontainers/runc: 5974b4c7 -> 34f23cb9
  - opencontainers/runc@5974b4c...34f23cb

Note: The etcd bump *does* include [a raft change](etcd-io/etcd#6935), but it is test only
  • Loading branch information
dt committed Dec 8, 2016
1 parent 76d810b commit 448fa23
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 42 deletions.
3 changes: 3 additions & 0 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ This snapshot was built and is managed using `glide`.
The [docs](https://github.com/Masterminds/glide) have detailed instructions, but in brief:
* run `./scripts/glide.sh` in `cockroachdb/cockroach`.
* add new dependencies with `./scripts/glide.sh get -s github.com/my/dependency`
nb: glide uses `import` statements as the starting point when determining what to vendor.
- if you are importing your new depenency in code, you should be fine.
- if you are not (e.g. a binary tool), you need to add it to build/tool_imports.go to force an import.
* update dependencies to their latest version with `./scripts/glide.sh up`
- to pin a dependency to a particular version, add a `version: ...` line to `glide.yaml`, then update.
- to update a pinned dependency, change the version in `glide.yaml`, then update.
Expand Down
48 changes: 48 additions & 0 deletions build/tool_imports.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2016 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// 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.

// +build glide

package main

// Our vendoring tool, glide, only considers imports as the set of roots used
// to compute the transitive closure of dependencies it should resolve.
// We depend on many tools which we don't actually import directly elsewhere –
// e.g in a `go generate` or our Makefiles – but convincing `glide` to vendor
// them, and their dependencies, is difficult: https://github.com/Masterminds/glide/issues/690
//
// Thus, instead of trying to use `glide get` or `glide.yaml` to document those
// additional dependency roots, we add fake imports here for glide to find.
// NB: Some of these are `package main` so they cannot acutally be imported, so
// this file is build-tagged +glide to prevent attempting to build it.

import (
_ "github.com/client9/misspell/cmd/misspell"
_ "github.com/cockroachdb/c-protobuf/cmd/protoc"
_ "github.com/cockroachdb/crlfmt"
_ "github.com/cockroachdb/stress"
_ "github.com/golang/lint/golint"
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway"
_ "github.com/jteeuwen/go-bindata/go-bindata"
_ "github.com/kisielk/errcheck"
_ "github.com/kkaneda/returncheck"
_ "github.com/mattn/goveralls"
_ "github.com/mdempsky/unconvert"
_ "github.com/mibk/dupl"
_ "github.com/robfig/glock"
_ "github.com/wadey/gocovmerge"
_ "golang.org/x/tools/cmd/goimports"
_ "golang.org/x/tools/cmd/goyacc"
_ "golang.org/x/tools/cmd/stringer"
)
40 changes: 28 additions & 12 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 0 additions & 29 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,10 @@ import:
version: 7248742ae7127347a52ab9d215451c213b7b59da
- package: github.com/gogo/protobuf
version: ccdc7fbcb4cd13f34b76d7262805e58316faaaf4
- package: github.com/grpc-ecosystem/grpc-gateway
subpackages:
- protoc-gen-grpc-gateway
- package: golang.org/x/net
version: 97edce0b2e423f6a8debb459af47f4a3cb4ff954
- package: google.golang.org/grpc
version: 79b7c349179cdd6efd8bac4a1ce7f01b98c16e9b
- package: github.com/jteeuwen/go-bindata
subpackages:
- go-bindata
- package: github.com/mattn/goveralls
- package: github.com/client9/misspell
subpackages:
- cmd/misspell
- package: github.com/cockroachdb/crlfmt
- package: github.com/cockroachdb/stress
- package: github.com/golang/lint
subpackages:
- golint
- package: github.com/kisielk/errcheck
- package: github.com/kkaneda/returncheck
- package: github.com/mdempsky/unconvert
- package: github.com/mibk/dupl
- package: github.com/robfig/glock
- package: github.com/wadey/gocovmerge
- package: golang.org/x/tools
subpackages:
- cmd/goimports
- cmd/goyacc
- cmd/stringer
- package: github.com/golang/glog
- package: github.com/pborman/uuid
- package: github.com/agtorre/gocolorize
- package: google.golang.org/api
version: 3ef9447cad8d725923ca024dab57786299cf745a
- package: cloud.google.com/go
Expand Down
2 changes: 1 addition & 1 deletion vendor
Submodule vendor updated 350 files

0 comments on commit 448fa23

Please sign in to comment.