commit
fa99193b7e
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue