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:
committed by
Sebastiaan van Stijn
parent
9eb632dc7c
commit
5400a48aaf
@ -37,7 +37,7 @@ func NewEventsCommand(dockerCli command.Cli) *cobra.Command {
|
||||
Short: "Get real time events from the server",
|
||||
Args: cli.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runEvents(dockerCli, &options)
|
||||
return runEvents(cmd.Context(), dockerCli, &options)
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
"aliases": "docker system events, docker events",
|
||||
@ -54,7 +54,7 @@ func NewEventsCommand(dockerCli command.Cli) *cobra.Command {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func runEvents(dockerCli command.Cli, options *eventsOptions) error {
|
||||
func runEvents(ctx context.Context, dockerCli command.Cli, options *eventsOptions) error {
|
||||
tmpl, err := makeTemplate(options.format)
|
||||
if err != nil {
|
||||
return cli.StatusError{
|
||||
@ -62,7 +62,7 @@ func runEvents(dockerCli command.Cli, options *eventsOptions) error {
|
||||
Status: "Error parsing format: " + err.Error(),
|
||||
}
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
evts, errs := dockerCli.Client().Events(ctx, types.EventsOptions{
|
||||
Since: options.since,
|
||||
Until: options.until,
|
||||
|
||||
Reference in New Issue
Block a user