Plumb contexts through commands

This is to prepare for otel support.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Brian Goff
2023-09-09 22:27:44 +00:00
committed by Sebastiaan van Stijn
parent 9eb632dc7c
commit 5400a48aaf
146 changed files with 409 additions and 470 deletions

View File

@ -26,7 +26,7 @@ func newDisconnectCommand(dockerCli command.Cli) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
opts.network = args[0]
opts.container = args[1]
return runDisconnect(dockerCli, opts)
return runDisconnect(cmd.Context(), dockerCli, opts)
},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
@ -43,10 +43,10 @@ func newDisconnectCommand(dockerCli command.Cli) *cobra.Command {
return cmd
}
func runDisconnect(dockerCli command.Cli, opts disconnectOptions) error {
func runDisconnect(ctx context.Context, dockerCli command.Cli, opts disconnectOptions) error {
client := dockerCli.Client()
return client.NetworkDisconnect(context.Background(), opts.network, opts.container, opts.force)
return client.NetworkDisconnect(ctx, opts.network, opts.container, opts.force)
}
func isConnected(network string) func(types.Container) bool {