try to find auth by adding https://

fixes #32

Signed-off-by: Jess Frazelle <acidburn@google.com>
This commit is contained in:
Jess Frazelle 2017-07-17 13:00:25 -04:00
parent 78e58d7811
commit 0499ee2f51
No known key found for this signature in database
GPG key ID: 18F3685C0022BFF3

View file

@ -37,9 +37,17 @@ func GetAuthConfig(c *cli.Context) (types.AuthConfig, error) {
// if they passed a specific registry, return those creds _if_ they exist
if c.GlobalString("registry") != "" {
// try with the user input
if creds, ok := dcfg.AuthConfigs[c.GlobalString("registry")]; ok {
return creds, nil
}
// add https:// to user input and try again
// see https://github.com/jessfraz/reg/issues/32
if !strings.HasPrefix(c.GlobalString("registry"), "https://") && !strings.HasPrefix(c.GlobalString("registry"), "http://") {
if creds, ok := dcfg.AuthConfigs["https://"+c.GlobalString("registry")]; ok {
return creds, nil
}
}
return types.AuthConfig{}, fmt.Errorf("No authentication credentials exist for %s", c.GlobalString("registry"))
}