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