MCPcopy
hub / github.com/containerd/containerd / NewStaticCredentials

Function NewStaticCredentials

cmd/ctr/commands/resolver.go:161–189  ·  view source on GitHub ↗

NewStaticCredentials gets credentials from passing in cli context

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

Source from the content-addressed store, hash-verified

159
160// NewStaticCredentials gets credentials from passing in cli context
161func NewStaticCredentials(ctx context.Context, cliContext *cli.Context, ref string) (registry.CredentialHelper, error) {
162 username := cliContext.String("user")
163 var secret string
164 if i := strings.IndexByte(username, ':'); i > 0 {
165 secret = username[i+1:]
166 username = username[0:i]
167 }
168 if username != "" {
169 if secret == "" {
170 fmt.Printf("Password: ")
171
172 var err error
173 secret, err = passwordPrompt()
174 if err != nil {
175 return nil, err
176 }
177
178 fmt.Print("\n")
179 }
180 } else if rt := cliContext.String("refresh"); rt != "" {
181 secret = rt
182 }
183
184 return &staticCredentials{
185 ref: ref,
186 username: username,
187 secret: secret,
188 }, nil
189}
190
191func (sc *staticCredentials) GetCredentials(ctx context.Context, ref, host string) (registry.Credentials, error) {
192 if ref == sc.ref {

Callers 2

push.goFile · 0.92
pull.goFile · 0.92

Calls 2

passwordPromptFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…