@ -96,23 +96,8 @@ func NewClient(options ...ClientOption) (*Client, error) {
return resolver , nil
}
}
headers := http . Header { }
headers . Set ( "User-Agent" , version . GetUserAgent ( ) )
dockerClient , ok := client . authorizer . ( * dockerauth . Client )
if ok {
username , password , err := dockerClient . Credential ( ref . Registry )
if err != nil {
return nil , fmt . Errorf ( "unable to retrieve credentials: %w" , err )
}
// A blank returned username and password value is a bearer token
if username == "" && password != "" {
headers . Set ( "Authorization" , fmt . Sprintf ( "Bearer %s" , password ) )
} else {
headers . Set ( "Authorization" , fmt . Sprintf ( "Basic %s" , basicAuth ( username , password ) ) )
}
}
opts := [ ] auth . ResolverOption { auth . WithResolverHeaders ( headers ) }
if client . httpClient != nil {
opts = append ( opts , auth . WithResolverClient ( client . httpClient ) )
@ -144,6 +129,7 @@ func NewClient(options ...ClientOption) (*Client, error) {
if ! ok {
return registryauth . EmptyCredential , errors . New ( "unable to obtain docker client" )
}
username , password , err := dockerClient . Credential ( reg )
if err != nil {
return registryauth . EmptyCredential , errors . New ( "unable to retrieve credentials" )
@ -607,6 +593,7 @@ func (c *Client) Push(data []byte, ref string, options ...PushOption) (*PushResu
if err := memoryStore . StoreManifest ( parsedRef . String ( ) , manifest , manifestData ) ; err != nil {
return nil , err
}
remotesResolver , err := c . resolver ( parsedRef )
if err != nil {
return nil , err