Skip to content

Commit eb4865f

Browse files
committed
Hack to ignore stale packages in godep
Change-Id: Ibf0877521310d6f2baad605bf1216940e95cb9cd
1 parent 317ecf5 commit eb4865f

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

hack/godep-save.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,23 @@ if [[ -d Godeps ]]; then
5252
mv Godeps "${BACKUP}/Godeps"
5353
fi
5454

55+
## Workaround "httplex" was dropped from golang.org/x/net repo and the code
56+
## was moved to the "golang.org/x/net/http/httpguts" directory, we do not use
57+
## this directly, however many packages we vendor are still using the older
58+
## golang.org/x/net and we need to keep this until all those dependencies
59+
## are switched to newer golang.org/x/net.
60+
IGNORED_PACKAGES=(
61+
"golang.org/x/net/lex/httplex"
62+
)
63+
REQUIRED_BINS=(
64+
"golang.org/x/net/internal/nettest"
65+
"golang.org/x/net/internal/socks"
66+
"golang.org/x/net/internal/sockstest"
67+
)
68+
5569
# Some things we want in godeps aren't code dependencies, so ./...
5670
# won't pick them up.
57-
REQUIRED_BINS=(
71+
REQUIRED_BINS+=(
5872
"github.com/bazelbuild/bazel-gazelle/cmd/gazelle"
5973
"github.com/bazelbuild/buildtools/buildozer"
6074
"github.com/cespare/prettybench"
@@ -74,7 +88,7 @@ kube::log::status "Running godep save - this might take a while"
7488
# This uses $(pwd) rather than ${KUBE_ROOT} because KUBE_ROOT will be
7589
# realpath'ed, and godep barfs ("... is not using a known version control
7690
# system") on our staging dirs.
77-
GOPATH="${GOPATH}:$(pwd)/staging" ${KUBE_GODEP:?} save "${REQUIRED_BINS[@]}"
91+
GOPATH="${GOPATH}:$(pwd)/staging" ${KUBE_GODEP:?} save -i $(IFS=,; echo "${IGNORED_PACKAGES[*]}") "${REQUIRED_BINS[@]}"
7892

7993
# create a symlink in vendor directory pointing to the staging client. This
8094
# let other packages use the staging client as if it were vendored.

third_party/forked/godep/pkg.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package main
22

33
import (
4+
"fmt"
45
"go/build"
6+
"os"
57
"regexp"
8+
"sort"
69
"strings"
710
)
811

@@ -42,9 +45,19 @@ func LoadPackages(names ...string) (a []*Package, err error) {
4245
if len(names) == 0 {
4346
return nil, nil
4447
}
48+
49+
pkgs := strings.Split(ignorePackages, ",")
50+
sort.Strings(pkgs)
4551
for _, i := range importPaths(names) {
4652
p, err := listPackage(i)
4753
if err != nil {
54+
if len(pkgs) > 0 {
55+
idx := sort.SearchStrings(pkgs, i)
56+
if idx < len(pkgs) && pkgs[idx] == i {
57+
fmt.Fprintf(os.Stderr, "warning: ignoring package %q \n", i)
58+
continue
59+
}
60+
}
4861
return nil, err
4962
}
5063
a = append(a, p)

third_party/forked/godep/save.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ For more about specifying packages, see 'go help packages'.
6464

6565
var (
6666
saveR, saveT bool
67+
ignorePackages string
6768
)
6869

6970
func init() {
7071
cmdSave.Flag.BoolVar(&saveR, "r", false, "rewrite import paths")
7172
cmdSave.Flag.BoolVar(&saveT, "t", false, "save test files")
73+
cmdSave.Flag.StringVar(&ignorePackages, "i", "", "list of packages to ignore separated by commas")
7274
}
7375

7476
func runSave(cmd *Command, args []string) {

0 commit comments

Comments
 (0)