Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
glide: add initial (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoops authored Nov 18, 2021
1 parent 19e487d commit 7528a36
Show file tree
Hide file tree
Showing 22 changed files with 11,530 additions and 0 deletions.
18 changes: 18 additions & 0 deletions deplist.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func GetDeps(fullPath string) ([]Dependency, Bitmask, error) {
pomPath := filepath.Join(fullPath, "pom.xml")
goPath := filepath.Join(fullPath, "go.mod")
goPkgPath := filepath.Join(fullPath, "Gopkg.lock")
glidePath := filepath.Join(fullPath, "glide.lock")
rubyPath := filepath.Join(fullPath, "Gemfile.lock")
pythonPath := filepath.Join(fullPath, "requirements.txt")

Expand Down Expand Up @@ -180,6 +181,23 @@ func GetDeps(fullPath string) ([]Dependency, Bitmask, error) {
return err
}

if len(pkgs) > 0 {
foundTypes.DepFoundAddFlag(LangGolang)
}
for _, goPkg := range pkgs {
d := Dependency{
DepType: LangGolang,
Path: goPkg.Name,
Version: goPkg.Version,
}
deps = append(deps, d)
}
case glidePath:
pkgs, err := scan.GetGlideDeps(path)
if err != nil {
return err
}

if len(pkgs) > 0 {
foundTypes.DepFoundAddFlag(LangGolang)
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ require (
github.com/sirupsen/logrus v1.8.1
golang.org/x/mod v0.4.2
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
62 changes: 62 additions & 0 deletions internal/scan/glide.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package scan

import (
"io/ioutil"
"path/filepath"

log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
)

type GlideDeps struct {
Name string
Version string
}

type glideDep struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Subpackages []string `yaml:"subpackages"`
}

type glideDeps struct {
Imports []glideDep
}

func GetGlideDeps(path string) ([]GlideDeps, error) {
log.Debugf("GetGlideDeps %s", path)

var deps glideDeps
var gathered []GlideDeps

yaml_file, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}

err = yaml.Unmarshal(yaml_file, &deps)

if err != nil {
return nil, err
}

for _, d := range deps.Imports {
gathered = append(gathered,
GlideDeps{
Name: d.Name,
Version: d.Version,
},
)

for _, subpackage := range d.Subpackages {
gathered = append(gathered,
GlideDeps{
Name: filepath.Join(d.Name, subpackage),
Version: d.Version,
},
)
}
}

return gathered, nil
}
50 changes: 50 additions & 0 deletions vendor/gopkg.in/yaml.v3/LICENSE

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

13 changes: 13 additions & 0 deletions vendor/gopkg.in/yaml.v3/NOTICE

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

150 changes: 150 additions & 0 deletions vendor/gopkg.in/yaml.v3/README.md

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

Loading

0 comments on commit 7528a36

Please sign in to comment.