From 0499ee2f5124c573b325fdb9f07032e470193368 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Mon, 17 Jul 2017 13:00:25 -0400 Subject: [PATCH] try to find auth by adding https:// fixes #32 Signed-off-by: Jess Frazelle --- utils/utils.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/utils/utils.go b/utils/utils.go index 3c5d5a87..6e309272 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -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")) }