From 9e024b23b169b1f6a12b1e16f33f6570989cfcdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 10 May 2024 15:17:56 +0200 Subject: [PATCH] Plumb context to API callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signatures of these functions were changed in 80d92fd45007b6395dc2db5f93def3b159dacd7f Signed-off-by: Paweł Gronowski --- cli/command/plugin/install.go | 5 ++--- cli/command/registry.go | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/command/plugin/install.go b/cli/command/plugin/install.go index f1aa9d872593..6d9ea7da5fda 100644 --- a/cli/command/plugin/install.go +++ b/cli/command/plugin/install.go @@ -136,13 +136,12 @@ func runInstall(ctx context.Context, dockerCli command.Cli, opts pluginOptions) return nil } -func acceptPrivileges(dockerCli command.Cli, name string) func(privileges types.PluginPrivileges) (bool, error) { - return func(privileges types.PluginPrivileges) (bool, error) { +func acceptPrivileges(dockerCli command.Cli, name string) func(ctx context.Context, privileges types.PluginPrivileges) (bool, error) { + return func(ctx context.Context, privileges types.PluginPrivileges) (bool, error) { fmt.Fprintf(dockerCli.Out(), "Plugin %q is requesting the following privileges:\n", name) for _, privilege := range privileges { fmt.Fprintf(dockerCli.Out(), " - %s: %v\n", privilege.Name, privilege.Value) } - ctx := context.TODO() return command.PromptForConfirmation(ctx, dockerCli.In(), dockerCli.Out(), "Do you grant the above permissions?") } } diff --git a/cli/command/registry.go b/cli/command/registry.go index a1a499eee46a..24b8757a8941 100644 --- a/cli/command/registry.go +++ b/cli/command/registry.go @@ -2,6 +2,7 @@ package command import ( "bufio" + "context" "fmt" "io" "os" @@ -27,7 +28,7 @@ const patSuggest = "You can log in with your password or a Personal Access " + // RegistryAuthenticationPrivilegedFunc returns a RequestPrivilegeFunc from the specified registry index info // for the given command. func RegistryAuthenticationPrivilegedFunc(cli Cli, index *registrytypes.IndexInfo, cmdName string) types.RequestPrivilegeFunc { - return func() (string, error) { + return func(_ context.Context) (string, error) { fmt.Fprintf(cli.Out(), "\nPlease login prior to %s:\n", cmdName) indexServer := registry.GetAuthConfigKey(index) isDefaultRegistry := indexServer == registry.IndexServer