From a90593da3d927e3df40203ad239e57cb178a9f55 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Sat, 7 Mar 2020 17:29:15 -0500 Subject: [PATCH] cmd/Go-Package-Store, updater: remove support for vendor.json file The govendor tool has been deprecated in favor of Go module mode, see https://github.com/kardianos/govendor/commit/e31350db9750308ce016ebef8350a8ff1e0a37d0. Remove all support for its vendor.json file format. Updates #92. --- README.md | 5 ----- cmd/Go-Package-Store/govendor.go | 19 ----------------- cmd/Go-Package-Store/main.go | 24 ---------------------- updater/govendor.go | 35 -------------------------------- 4 files changed, 83 deletions(-) delete mode 100644 cmd/Go-Package-Store/govendor.go delete mode 100644 updater/govendor.go diff --git a/README.md b/README.md index a9fa6c2..72d1dbf 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,6 @@ Usage: Go-Package-Store [flags] Look for Go packages vendored using git-subrepo in the specified vendor directory. -godeps string Read the list of Go packages from the specified Godeps.json file. - -govendor string - Read the list of Go packages from the specified vendor.json file. -http string Listen for HTTP connections on this address. (default "localhost:7043") -stdin @@ -51,9 +49,6 @@ Examples: # Show updates for all dependencies within Gopkg.toml constraints. Go-Package-Store -dep=/path/to/repo/Gopkg.toml - # Show updates for all dependencies listed in vendor.json file. - Go-Package-Store -govendor=/path/to/repo/vendor/vendor.json - # Show updates for all Go packages vendored using git-subrepo # in the specified vendor directory. Go-Package-Store -git-subrepo=/path/to/repo/vendor diff --git a/cmd/Go-Package-Store/govendor.go b/cmd/Go-Package-Store/govendor.go deleted file mode 100644 index 1d0ae2d..0000000 --- a/cmd/Go-Package-Store/govendor.go +++ /dev/null @@ -1,19 +0,0 @@ -package main - -import ( - "os" - - "github.com/kardianos/govendor/vendorfile" -) - -// readGovendor reads a vendor.json file at path. -func readGovendor(path string) (vendorfile.File, error) { - f, err := os.Open(path) - if err != nil { - return vendorfile.File{}, err - } - defer f.Close() - var v vendorfile.File - err = v.Unmarshal(f) - return v, err -} diff --git a/cmd/Go-Package-Store/main.go b/cmd/Go-Package-Store/main.go index 8d8f876..24f6992 100644 --- a/cmd/Go-Package-Store/main.go +++ b/cmd/Go-Package-Store/main.go @@ -31,7 +31,6 @@ var ( stdinFlag = flag.Bool("stdin", false, "Read the list of newline separated Go packages from stdin.") depFlag = flag.String("dep", "", "Determine the list of Go packages from the specified Gopkg.toml file.") godepsFlag = flag.String("godeps", "", "Read the list of Go packages from the specified Godeps.json file.") - govendorFlag = flag.String("govendor", "", "Read the list of Go packages from the specified vendor.json file.") gitSubrepoFlag = flag.String("git-subrepo", "", "Look for Go packages vendored using git-subrepo in the specified vendor directory.") ) @@ -56,9 +55,6 @@ Examples: # Show updates for all dependencies within Gopkg.toml constraints. Go-Package-Store -dep=/path/to/repo/Gopkg.toml - # Show updates for all dependencies listed in vendor.json file. - Go-Package-Store -govendor=/path/to/repo/vendor/vendor.json - # Show updates for all Go packages vendored using git-subrepo # in the specified vendor directory. Go-Package-Store -git-subrepo=/path/to/repo/vendor @@ -229,26 +225,6 @@ func populatePipelineAndCreateUpdater(pipeline *workspace.Pipeline) gps.Updater pipeline.Done() }() return nil - case *govendorFlag != "": - fmt.Println("Reading the list of Go packages from vendor.json file:", *govendorFlag) - v, err := readGovendor(*govendorFlag) - if err != nil { - log.Fatalln("failed to read vendor.json file:", err) - } - go func() { // This needs to happen in the background because sending input will be blocked on processing. - for _, dependency := range v.Package { - pipeline.AddRevision(dependency.Path, dependency.Revision) - } - pipeline.Done() - }() - // TODO: Consider setting a better directory for govendor command than current working directory. - // Perhaps the parent directory of vendor.json file? - gu, err := updater.NewGovendor("") - if err != nil { - log.Println("govendor updater is not available:", err) - gu = nil - } - return gu case *gitSubrepoFlag != "": if _, err := exec.LookPath("git"); err != nil { log.Fatalln(fmt.Errorf("git binary is required, but not available: %v", err)) diff --git a/updater/govendor.go b/updater/govendor.go deleted file mode 100644 index 7ec58ff..0000000 --- a/updater/govendor.go +++ /dev/null @@ -1,35 +0,0 @@ -package updater - -import ( - "fmt" - "os" - "os/exec" - "strings" - - "github.com/shurcooL/Go-Package-Store" -) - -// NewGovendor returns an Updater that updates Go packages listed in vendor.json. -// dir controls where the `govendor` binary is executed. If empty string, current working -// directory is used. If `govendor` binary is not available in PATH, an error will be returned. -func NewGovendor(dir string) (gps.Updater, error) { - if _, err := exec.LookPath("govendor"); err != nil { - return nil, fmt.Errorf("govendor binary is required for updating, but not available: %v", err) - } - return govendor{dir: dir}, nil -} - -// govendor is an Updater that updates Go packages listed in vendor.json. -type govendor struct { - dir string // Where to execute `govendor` binary. -} - -func (gu govendor) Update(repo *gps.Repo) error { - cmd := exec.Command("govendor", "fetch", repo.ImportPathPattern()+"@"+repo.Remote.Revision) - fmt.Print(strings.Join(cmd.Args, " ")) - cmd.Dir = gu.dir - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err := cmd.Run() - return err -}