cmd: don't alias context package, and use cliContext for cli.Context

Unfortunately, this is a rather large diff, but perhaps worth a one-time
"rip off the bandaid" for v2. This patch removes the use of "gocontext"
as alias for stdLib's "context", and uses "cliContext" for uses of
cli.context.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2024-06-20 02:15:13 +02:00
parent 741c4bde51
commit dd0542f7c1
65 changed files with 754 additions and 755 deletions

View File

@@ -44,12 +44,12 @@ var checkpointCommand = &cli.Command{
Usage: "Path to criu work files and logs",
},
},
Action: func(context *cli.Context) error {
id := context.Args().First()
Action: func(cliContext *cli.Context) error {
id := cliContext.Args().First()
if id == "" {
return errors.New("container id must be provided")
}
client, ctx, cancel, err := commands.NewClient(context, containerd.WithDefaultRuntime(context.String("runtime")))
client, ctx, cancel, err := commands.NewClient(cliContext, containerd.WithDefaultRuntime(cliContext.String("runtime")))
if err != nil {
return err
}
@@ -66,12 +66,12 @@ var checkpointCommand = &cli.Command{
if err != nil {
return err
}
opts := []containerd.CheckpointTaskOpts{withCheckpointOpts(info.Runtime.Name, context)}
opts := []containerd.CheckpointTaskOpts{withCheckpointOpts(info.Runtime.Name, cliContext)}
checkpoint, err := task.Checkpoint(ctx, opts...)
if err != nil {
return err
}
if context.String("image-path") == "" {
if cliContext.String("image-path") == "" {
fmt.Println(checkpoint.Name())
}
return nil
@@ -79,17 +79,17 @@ var checkpointCommand = &cli.Command{
}
// withCheckpointOpts only suitable for runc runtime now
func withCheckpointOpts(rt string, context *cli.Context) containerd.CheckpointTaskOpts {
func withCheckpointOpts(rt string, cliContext *cli.Context) containerd.CheckpointTaskOpts {
return func(r *containerd.CheckpointTaskInfo) error {
imagePath := context.String("image-path")
workPath := context.String("work-path")
imagePath := cliContext.String("image-path")
workPath := cliContext.String("work-path")
if r.Options == nil {
r.Options = &options.CheckpointOptions{}
}
opts, _ := r.Options.(*options.CheckpointOptions)
if context.Bool("exit") {
if cliContext.Bool("exit") {
opts.Exit = true
}
if imagePath != "" {