Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/imgutil/dockerconfigresolver/dockerconfigresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ import (
"crypto/tls"
"errors"
"fmt"
"net/http"
"os"

"github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker"
dockerconfig "github.com/containerd/containerd/remotes/docker/config"
containerdversion "github.com/containerd/containerd/version"
nerdctlversion "github.com/containerd/nerdctl/pkg/version"
dockercliconfig "github.com/docker/cli/cli/config"
"github.com/docker/cli/cli/config/credentials"
dockercliconfigtypes "github.com/docker/cli/cli/config/types"
Expand All @@ -36,6 +39,8 @@ import (

var PushTracker = docker.NewInMemoryTracker()

var userAgentValue = fmt.Sprintf("nerdctl/%s containerd/%s", nerdctlversion.Version, containerdversion.Version)

type opts struct {
plainHTTP bool
skipVerifyCerts bool
Expand Down Expand Up @@ -136,6 +141,8 @@ func NewHostOptions(ctx context.Context, refHostname string, optFuncs ...Opt) (*
ho.DefaultScheme = "http"
}
}

ho.AuthorizerOpts = append(ho.AuthorizerOpts, docker.WithAuthHeader(http.Header{"User-Agent": []string{userAgentValue}}))
return &ho, nil
}

Expand All @@ -153,6 +160,7 @@ func New(ctx context.Context, refHostname string, optFuncs ...Opt) (remotes.Reso
resolverOpts := docker.ResolverOptions{
Tracker: PushTracker,
Hosts: dockerconfig.ConfigureHosts(ctx, *ho),
Headers: http.Header{"User-Agent": []string{userAgentValue}},
}

resolver := docker.NewResolver(resolverOpts)
Expand Down