Skip to content

Commit ae9569c

Browse files
committed
cli/command: remove NewAuthRequester as its now unused
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 851d30f commit ae9569c

File tree

1 file changed

+0
-38
lines changed

1 file changed

+0
-38
lines changed

cli/command/registry.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,44 +34,6 @@ const (
3434
// [registry.IndexServer]: https://pkg.go.dev/github.com/docker/[email protected]+incompatible/registry#IndexServer
3535
const authConfigKey = "https://index.docker.io/v1/"
3636

37-
// NewAuthRequester returns a RequestPrivilegeFunc for the specified registry
38-
// and the given cmdName (used as informational message to the user).
39-
//
40-
// The returned function is a [registrytypes.RequestAuthConfig] to prompt the user
41-
// for credentials if needed. It is called as fallback if the credentials (if any)
42-
// used for the initial operation did not work.
43-
//
44-
// TODO(thaJeztah): cli Cli could be a Streams if it was not for cli.SetIn to be needed?
45-
// TODO(thaJeztah): ideally, this would accept reposName / imageRef as a regular string (we can parse it if needed!), or .. maybe generics and accept either?
46-
func NewAuthRequester(cli Cli, indexServer string, promptMsg string) registrytypes.RequestAuthConfig {
47-
configKey := getAuthConfigKey(indexServer)
48-
return newPrivilegeFunc(cli, configKey, promptMsg)
49-
}
50-
51-
func newPrivilegeFunc(cli Cli, indexServer string, promptMsg string) registrytypes.RequestAuthConfig {
52-
return func(ctx context.Context) (string, error) {
53-
// TODO(thaJeztah): can we make the prompt an argument? ("prompt func()" or "prompt func()?
54-
_, _ = fmt.Fprint(cli.Out(), "\n"+promptMsg+"\n")
55-
isDefaultRegistry := indexServer == authConfigKey
56-
authConfig, err := GetDefaultAuthConfig(cli.ConfigFile(), true, indexServer, isDefaultRegistry)
57-
if err != nil {
58-
_, _ = fmt.Fprintf(cli.Err(), "Unable to retrieve stored credentials for %s, error: %s.\n", indexServer, err)
59-
}
60-
61-
select {
62-
case <-ctx.Done():
63-
return "", ctx.Err()
64-
default:
65-
}
66-
67-
authConfig, err = PromptUserForCredentials(ctx, cli, "", "", authConfig.Username, indexServer)
68-
if err != nil {
69-
return "", err
70-
}
71-
return registrytypes.EncodeAuthConfig(authConfig)
72-
}
73-
}
74-
7537
// ResolveAuthConfig returns auth-config for the given registry from the
7638
// credential-store. It returns an empty AuthConfig if no credentials were
7739
// found.

0 commit comments

Comments
 (0)