Merge pull request #30963 from TerryHowe/oras-v2-login

Fix Oras v2 login
pull/31005/head
Robert Sirchia 3 months ago committed by GitHub
commit d823a497a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -289,17 +289,17 @@ func (c *Client) Login(host string, options ...LoginOption) error {
return err return err
} }
reg.PlainHTTP = c.plainHTTP reg.PlainHTTP = c.plainHTTP
cred := auth.Credential{Username: c.username, Password: c.password}
c.authorizer.ForceAttemptOAuth2 = true
reg.Client = c.authorizer reg.Client = c.authorizer
ctx := context.Background() ctx := context.Background()
cred, err := c.authorizer.Credential(ctx, host) if err := reg.Ping(ctx); err != nil {
if err != nil { c.authorizer.ForceAttemptOAuth2 = false
return fmt.Errorf("fetching credentials for %q: %w", host, err)
}
if err := reg.Ping(ctx); err != nil { if err := reg.Ping(ctx); err != nil {
return fmt.Errorf("authenticating to %q: %w", host, err) return fmt.Errorf("authenticating to %q: %w", host, err)
} }
}
// The credentialsStore loader does not handle empty files. So, there is a workaround. // The credentialsStore loader does not handle empty files. So, there is a workaround.
// This can be removed when the credentials loader can handle empty files. // This can be removed when the credentials loader can handle empty files.

Loading…
Cancel
Save