|
|
@ -96,23 +96,8 @@ func NewClient(options ...ClientOption) (*Client, error) {
|
|
|
|
return resolver, nil
|
|
|
|
return resolver, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
headers := http.Header{}
|
|
|
|
headers := http.Header{}
|
|
|
|
headers.Set("User-Agent", version.GetUserAgent())
|
|
|
|
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)}
|
|
|
|
opts := []auth.ResolverOption{auth.WithResolverHeaders(headers)}
|
|
|
|
if client.httpClient != nil {
|
|
|
|
if client.httpClient != nil {
|
|
|
|
opts = append(opts, auth.WithResolverClient(client.httpClient))
|
|
|
|
opts = append(opts, auth.WithResolverClient(client.httpClient))
|
|
|
@ -144,6 +129,7 @@ func NewClient(options ...ClientOption) (*Client, error) {
|
|
|
|
if !ok {
|
|
|
|
if !ok {
|
|
|
|
return registryauth.EmptyCredential, errors.New("unable to obtain docker client")
|
|
|
|
return registryauth.EmptyCredential, errors.New("unable to obtain docker client")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
username, password, err := dockerClient.Credential(reg)
|
|
|
|
username, password, err := dockerClient.Credential(reg)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return registryauth.EmptyCredential, errors.New("unable to retrieve credentials")
|
|
|
|
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 {
|
|
|
|
if err := memoryStore.StoreManifest(parsedRef.String(), manifest, manifestData); err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
remotesResolver, err := c.resolver(parsedRef)
|
|
|
|
remotesResolver, err := c.resolver(parsedRef)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|