lint and cleanup

Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
This commit is contained in:
Jess Frazelle 2018-03-06 09:19:55 -05:00
parent a3b459b1a5
commit 0cb8777fb1
No known key found for this signature in database
GPG key ID: 18F3685C0022BFF3
5 changed files with 31 additions and 34 deletions

View file

@ -60,9 +60,7 @@ func (c *Clair) Vulnerabilities(r *registry.Registry, repo, tag string) (Vulnera
// Get the vulns.
for _, f := range vl.Features {
for _, v := range f.Vulnerabilities {
report.Vulns = append(report.Vulns, v)
}
report.Vulns = append(report.Vulns, f.Vulnerabilities...)
}
vulnsBy := func(sev string, store map[string][]Vulnerability) []Vulnerability {

54
main.go
View file

@ -13,10 +13,6 @@ import (
"github.com/urfave/cli"
)
const (
dockerConfigPath = ".docker/config.json"
)
var (
auth types.AuthConfig
r *registry.Registry
@ -74,31 +70,37 @@ func main() {
logrus.SetLevel(logrus.DebugLevel)
}
if len(c.Args()) > 0 {
if c.Args()[0] != "help" {
auth, err = repoutils.GetAuthConfig(c.GlobalString("username"), c.GlobalString("password"), c.GlobalString("registry"))
if err != nil {
return err
}
if len(c.Args()) == 0 {
return
}
// Prevent non-ssl unless explicitly forced
if !c.GlobalBool("force-non-ssl") && strings.HasPrefix(auth.ServerAddress, "http:") {
return fmt.Errorf("Attempt to use insecure protocol! Use non-ssl option to force")
}
if c.Args()[0] == "help" {
return
}
// create the registry client
if c.GlobalBool("insecure") {
r, err = registry.NewInsecure(auth, c.GlobalBool("debug"))
if err != nil {
return err
}
} else {
r, err = registry.New(auth, c.GlobalBool("debug"))
if err != nil {
return err
}
}
auth, err = repoutils.GetAuthConfig(c.GlobalString("username"), c.GlobalString("password"), c.GlobalString("registry"))
if err != nil {
return err
}
// Prevent non-ssl unless explicitly forced
if !c.GlobalBool("force-non-ssl") && strings.HasPrefix(auth.ServerAddress, "http:") {
return fmt.Errorf("Attempt to use insecure protocol! Use non-ssl option to force")
}
// create the registry client
if c.GlobalBool("insecure") {
r, err = registry.NewInsecure(auth, c.GlobalBool("debug"))
if err != nil {
return err
}
return
}
r, err = registry.New(auth, c.GlobalBool("debug"))
if err != nil {
return err
}
return nil

View file

@ -5,6 +5,7 @@ import (
"net/http"
"net/url"
"github.com/docker/distribution/reference"
"github.com/opencontainers/go-digest"
)
@ -22,7 +23,7 @@ func (r *Registry) DownloadLayer(repository string, digest digest.Digest) (io.Re
}
// UploadLayer uploads a specific layer by digest for a repository.
func (r *Registry) UploadLayer(repository string, digest digest.Digest, content io.Reader) error {
func (r *Registry) UploadLayer(repository string, digest reference.Reference, content io.Reader) error {
uploadURL, err := r.initiateUpload(repository)
if err != nil {
return err

View file

@ -188,7 +188,6 @@ func (rc *registryController) tagsHandler(w http.ResponseWriter, r *http.Request
w.WriteHeader(http.StatusInternalServerError)
return
}
return
}
func (rc *registryController) vulnerabilitiesHandler(w http.ResponseWriter, r *http.Request) {
@ -255,5 +254,4 @@ func (rc *registryController) vulnerabilitiesHandler(w http.ResponseWriter, r *h
w.WriteHeader(http.StatusInternalServerError)
return
}
return
}

View file

@ -20,8 +20,6 @@ import (
const (
// VERSION is the binary version.
VERSION = "v0.2.0"
dockerConfigPath = ".docker/config.json"
)
var (