Merge branch 'majst01-make-tls-verify-optional'

* majst01-make-tls-verify-optional:
  Fix method signature
  Make tls verification optional
This commit is contained in:
Jess Frazelle 2017-02-13 11:38:20 -08:00
commit f2811e79e2
No known key found for this signature in database
GPG key ID: 18F3685C0022BFF3
3 changed files with 11 additions and 4 deletions

View file

@ -46,7 +46,7 @@ func preload(c *cli.Context) (err error) {
} }
// create the registry client // create the registry client
r, err = registry.New(auth, c.GlobalBool("debug")) r, err = registry.New(auth, c.GlobalBool("debug"), c.GlobalBool("skipverify"))
if err != nil { if err != nil {
return err return err
} }
@ -69,6 +69,10 @@ func main() {
Name: "debug, d", Name: "debug, d",
Usage: "run in debug mode", Usage: "run in debug mode",
}, },
cli.BoolFlag{
Name: "skipverify, k",
Usage: "do not verify tls certificates",
},
cli.StringFlag{ cli.StringFlag{
Name: "username, u", Name: "username, u",
Usage: "username for the registry", Usage: "username for the registry",

View file

@ -33,8 +33,11 @@ func Log(format string, args ...interface{}) {
} }
// New creates a new Registry struct with the given URL and credentials. // New creates a new Registry struct with the given URL and credentials.
func New(auth types.AuthConfig, debug bool) (*Registry, error) { func New(auth types.AuthConfig, debug bool, skipverify bool) (*Registry, error) {
transport := http.DefaultTransport transport := http.DefaultTransport.(*http.Transport)
transport.TLSClientConfig = &tls.Config{
InsecureSkipVerify: skipverify,
}
return newFromTransport(auth, transport, debug) return newFromTransport(auth, transport, debug)
} }

View file

@ -93,7 +93,7 @@ func main() {
} }
// create the registry client // create the registry client
r, err := registry.New(auth, c.GlobalBool("debug")) r, err := registry.New(auth, c.GlobalBool("debug"), c.GlobalBool("skipverify"))
if err != nil { if err != nil {
return err return err
} }