Merge pull request #169 from keel-hq/feature/insecure_registries

insecure registry
pull/170/head
Karolis Rusenas 2018-03-27 14:11:05 +01:00 committed by GitHub
commit fa99193b7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 3 deletions

View File

@ -2,12 +2,16 @@ package registry
import ( import (
"errors" "errors"
"os"
"github.com/rusenask/docker-registry-client/registry" "github.com/rusenask/docker-registry-client/registry"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
// EnvInsecure - uses insecure registry client to skip cert verification
const EnvInsecure = "INSECURE_REGISTRY"
// errors // errors
var ( var (
ErrTagNotSupplied = errors.New("tag not supplied") ErrTagNotSupplied = errors.New("tag not supplied")
@ -50,10 +54,22 @@ func LogFormatter(format string, args ...interface{}) {
func (c *DefaultClient) Get(opts Opts) (*Repository, error) { func (c *DefaultClient) Get(opts Opts) (*Repository, error) {
repo := &Repository{} repo := &Repository{}
hub, err := registry.New(opts.Registry, opts.Username, opts.Password)
if err != nil { var hub *registry.Registry
return nil, err var err error
if os.Getenv(EnvInsecure) == "true" {
hub, err = registry.NewInsecure(opts.Registry, opts.Username, opts.Password)
if err != nil {
return nil, err
}
} else {
hub, err = registry.New(opts.Registry, opts.Username, opts.Password)
if err != nil {
return nil, err
}
} }
hub.Logf = LogFormatter hub.Logf = LogFormatter
tags, err := hub.Tags(opts.Name) tags, err := hub.Tags(opts.Name)