MCPcopy Index your code
hub / github.com/containerd/containerd / GetResolver

Function GetResolver

cmd/ctr/commands/resolver.go:58–112  ·  view source on GitHub ↗

GetResolver prepares the resolver from the environment and options

(ctx context.Context, cliContext *cli.Context)

Source from the content-addressed store, hash-verified

56
57// GetResolver prepares the resolver from the environment and options
58func GetResolver(ctx context.Context, cliContext *cli.Context) (remotes.Resolver, error) {
59 username := cliContext.String("user")
60 var secret string
61 if i := strings.IndexByte(username, ':'); i > 0 {
62 secret = username[i+1:]
63 username = username[0:i]
64 }
65 options := docker.ResolverOptions{
66 Tracker: PushTracker,
67 }
68 if username != "" {
69 if secret == "" {
70 fmt.Printf("Password: ")
71
72 var err error
73 secret, err = passwordPrompt()
74 if err != nil {
75 return nil, err
76 }
77
78 fmt.Print("\n")
79 }
80 } else if rt := cliContext.String("refresh"); rt != "" {
81 secret = rt
82 }
83
84 hostOptions := config.HostOptions{}
85 hostOptions.Credentials = func(host string) (string, string, error) {
86 // If host doesn't match...
87 // Only one host
88 return username, secret, nil
89 }
90 if cliContext.Bool("plain-http") {
91 hostOptions.DefaultScheme = "http"
92 }
93 defaultTLS, err := resolverDefaultTLS(cliContext)
94 if err != nil {
95 return nil, err
96 }
97 hostOptions.DefaultTLS = defaultTLS
98 if hostDir := cliContext.String("hosts-dir"); hostDir != "" {
99 hostOptions.HostDir = config.HostDirFromRoot(hostDir)
100 }
101
102 if cliContext.Bool("http-dump") {
103 hostOptions.UpdateClient = func(client *http.Client) error {
104 httpdbg.DumpRequests(ctx, client, nil)
105 return nil
106 }
107 }
108
109 options.Hosts = config.ConfigureHosts(ctx, hostOptions)
110
111 return docker.NewResolver(options), nil
112}
113
114func resolverDefaultTLS(cliContext *cli.Context) (*tls.Config, error) {
115 tlsConfig := &tls.Config{}

Callers 3

NewFetchConfigFunction · 0.92
content.goFile · 0.92
push.goFile · 0.92

Calls 7

HostDirFromRootFunction · 0.92
DumpRequestsFunction · 0.92
ConfigureHostsFunction · 0.92
NewResolverFunction · 0.92
passwordPromptFunction · 0.85
resolverDefaultTLSFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…