Skip to content

migrate to github.com/urfave/cli/v3 - #14095

Merged
dmcgowan merged 1 commit into
containerd:mainfrom
thaJeztah:urfave_v3
Sep 10, 2026
Merged

dmcgowan merged 1 commit into
containerd:mainfrom
thaJeztah:urfave_v3

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are confirmed build-breaking issues in the v3 migration (e.g., remaining *cli.Context usage and vendored cli/v3 generic flag code that won’t compile) that must be fixed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR migrates containerd’s CLI tooling from github.com/urfave/cli/v2 to github.com/urfave/cli/v3, updating command/action signatures to use context.Context + *cli.Command, and updating vendored dependencies accordingly.

Changes:

  • Switch CLI dependency from urfave/cli/v2 to urfave/cli/v3 (plus urfave/cli-docs/v3) and update vendoring metadata.
  • Update containerd, ctr, and many ctr subcommands to the v3 command model (Run(ctx, args), Commands, new flag APIs).
  • Remove the github.com/xrash/smetrics vendor tree that was previously pulled in via cli/v2 suggestions.
File summaries
File Description
vendor/modules.txt Update vendored module list for cli/v3 and cli-docs/v3, drop cli/v2 and smetrics.
vendor/github.com/xrash/smetrics/wagner-fischer.go Remove vendored smetrics implementation.
vendor/github.com/xrash/smetrics/ukkonen.go Remove vendored smetrics implementation.
vendor/github.com/xrash/smetrics/soundex.go Remove vendored smetrics implementation.
vendor/github.com/xrash/smetrics/jaro.go Remove vendored smetrics implementation.
vendor/github.com/xrash/smetrics/jaro-winkler.go Remove vendored smetrics implementation.
vendor/github.com/xrash/smetrics/hamming.go Remove vendored smetrics implementation.
vendor/github.com/xrash/smetrics/doc.go Remove vendored smetrics package docs.
vendor/github.com/xrash/smetrics/README.md Remove vendored smetrics README.
vendor/github.com/xrash/smetrics/LICENSE Remove vendored smetrics license file.
vendor/github.com/xrash/smetrics/.travis.yml Remove vendored smetrics CI config.
vendor/github.com/urfave/cli/v3/staticcheck.conf Add vendored cli/v3 staticcheck config.
vendor/github.com/urfave/cli/v3/sort.go Add vendored cli/v3 sorting helper.
vendor/github.com/urfave/cli/v3/README.md Add vendored cli/v3 README.
vendor/github.com/urfave/cli/v3/mkdocs.yml Add vendored cli/v3 docs site config.
vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt Add vendored cli/v3 docs requirements.
vendor/github.com/urfave/cli/v3/Makefile Add vendored cli/v3 build helpers.
vendor/github.com/urfave/cli/v3/LICENSE Add vendored cli/v3 license.
vendor/github.com/urfave/cli/v3/funcs.go Add/update vendored cli/v3 callback type definitions.
vendor/github.com/urfave/cli/v3/flag_uint.go Add vendored cli/v3 uint flags.
vendor/github.com/urfave/cli/v3/flag_uint_slice.go Add vendored cli/v3 uint slice flags.
vendor/github.com/urfave/cli/v3/flag_timestamp.go Add vendored cli/v3 timestamp flags.
vendor/github.com/urfave/cli/v3/flag_string.go Add vendored cli/v3 string flags.
vendor/github.com/urfave/cli/v3/flag_string_slice.go Add vendored cli/v3 string slice flags.
vendor/github.com/urfave/cli/v3/flag_string_map.go Add vendored cli/v3 string map flags.
vendor/github.com/urfave/cli/v3/flag_slice_base.go Add vendored cli/v3 generic slice flag implementation.
vendor/github.com/urfave/cli/v3/flag_number_slice.go Add vendored cli/v3 numeric slice helpers.
vendor/github.com/urfave/cli/v3/flag_mutex.go Add vendored cli/v3 mutually-exclusive flag groups.
vendor/github.com/urfave/cli/v3/flag_map_impl.go Add vendored cli/v3 generic map flag implementation.
vendor/github.com/urfave/cli/v3/flag_int.go Add vendored cli/v3 int flags.
vendor/github.com/urfave/cli/v3/flag_int_slice.go Add vendored cli/v3 int slice flags.
vendor/github.com/urfave/cli/v3/flag_generic.go Add vendored cli/v3 generic flags.
vendor/github.com/urfave/cli/v3/flag_float.go Add vendored cli/v3 float flags.
vendor/github.com/urfave/cli/v3/flag_float_slice.go Add vendored cli/v3 float slice flags.
vendor/github.com/urfave/cli/v3/flag_ext.go Add vendored cli/v3 adapter for stdlib flags.
vendor/github.com/urfave/cli/v3/flag_duration.go Add vendored cli/v3 duration flags.
vendor/github.com/urfave/cli/v3/flag_bool.go Add vendored cli/v3 bool flags.
vendor/github.com/urfave/cli/v3/errors.go Update vendored cli/v3 error types/formatting.
vendor/github.com/urfave/cli/v3/docs.go Add vendored cli/v3 help/docs formatting helpers.
vendor/github.com/urfave/cli/v3/completion.go Add vendored cli/v3 shell completion command + embedded scripts.
vendor/github.com/urfave/cli/v3/CODE_OF_CONDUCT.md Add vendored cli/v3 CoC.
vendor/github.com/urfave/cli/v3/cli.go Add vendored cli/v3 package-level helpers (trace, etc.).
vendor/github.com/urfave/cli/v3/category.go Add vendored cli/v3 flag categorization logic.
vendor/github.com/urfave/cli/v3/autocomplete/zsh_autocomplete Add vendored cli/v3 zsh completion script.
vendor/github.com/urfave/cli/v3/autocomplete/powershell_autocomplete.ps1 Add vendored cli/v3 PowerShell completion script.
vendor/github.com/urfave/cli/v3/autocomplete/fish_autocomplete Add vendored cli/v3 fish completion script.
vendor/github.com/urfave/cli/v3/autocomplete/bash_autocomplete Add vendored cli/v3 bash completion script.
vendor/github.com/urfave/cli/v3/.golangci.yaml Add vendored cli/v3 lint config.
vendor/github.com/urfave/cli/v3/.gitignore Add vendored cli/v3 gitignore.
vendor/github.com/urfave/cli/v3/flag_impl.go Add vendored cli/v3 generic flag base implementation.
vendor/github.com/urfave/cli/v2/suggestions.go Remove vendored cli/v2 suggestion feature (and smetrics dependency).
vendor/github.com/urfave/cli/v2/README.md Remove vendored cli/v2 README.
vendor/github.com/urfave/cli/v2/parse.go Remove vendored cli/v2 parsing helpers.
vendor/github.com/urfave/cli/v2/mkdocs-reqs.txt Remove vendored cli/v2 docs requirements.
vendor/github.com/urfave/cli/v2/flag-spec.yaml Remove vendored cli/v2 flag generator spec.
vendor/github.com/urfave/cli/v2/flag_uint64.go Remove vendored cli/v2 flag implementation.
vendor/github.com/urfave/cli/v2/flag_uint.go Remove vendored cli/v2 flag implementation.
vendor/github.com/urfave/cli/v2/flag_string.go Remove vendored cli/v2 flag implementation.
vendor/github.com/urfave/cli/v2/flag_path.go Remove vendored cli/v2 flag implementation.
vendor/github.com/urfave/cli/v2/flag_int64.go Remove vendored cli/v2 flag implementation.
vendor/github.com/urfave/cli/v2/flag_int.go Remove vendored cli/v2 flag implementation.
vendor/github.com/urfave/cli/v2/flag_generic.go Remove vendored cli/v2 flag implementation.
vendor/github.com/urfave/cli/v2/flag_float64.go Remove vendored cli/v2 flag implementation.
vendor/github.com/urfave/cli/v2/flag_ext.go Remove vendored cli/v2 stdlib-flag adapter.
vendor/github.com/urfave/cli/v2/flag_duration.go Remove vendored cli/v2 flag implementation.
vendor/github.com/urfave/cli/v2/flag_bool.go Remove vendored cli/v2 flag implementation.
vendor/github.com/urfave/cli/v2/cli.go Remove vendored cli/v2 package stub.
vendor/github.com/urfave/cli/v2/args.go Remove vendored cli/v2 args type.
vendor/github.com/urfave/cli/v2/.flake8 Remove vendored cli/v2 lint config.
vendor/github.com/urfave/cli-docs/v3/README.md Add vendored cli-docs/v3 readme and examples.
vendor/github.com/urfave/cli-docs/v3/markdown.md.gotmpl Add vendored cli-docs/v3 markdown template.
vendor/github.com/urfave/cli-docs/v3/markdown_tabular.md.gotmpl Add vendored cli-docs/v3 tabular markdown template.
vendor/github.com/urfave/cli-docs/v3/Makefile Add vendored cli-docs/v3 build/test targets.
vendor/github.com/urfave/cli-docs/v3/LICENSE Update vendored cli-docs/v3 license header.
vendor/github.com/urfave/cli-docs/v3/CODE_OF_CONDUCT.md Add vendored cli-docs/v3 CoC.
vendor/github.com/urfave/cli-docs/v3/.golangci.yaml Update vendored cli-docs/v3 lints.
vendor/github.com/urfave/cli-docs/v3/.gitignore Update vendored cli-docs/v3 gitignore.
vendor/github.com/urfave/cli-docs/v3/.gitattributes Add vendored cli-docs/v3 attributes.
go.sum Update module checksums for new dependencies.
go.mod Swap required module from cli/v2 to cli/v3 and add cli-docs/v3.
cmd/gen-manpages/main.go Update manpage generation tool to v3 command model and cli-docs.
cmd/ctr/main.go Update ctr entrypoint to Run(ctx, args) with background context.
cmd/ctr/commands/version/version.go Update version subcommand to v3 action signature and args handling.
cmd/ctr/commands/tasks/tasks.go Update tasks command to use Commands field (v3) and v3 imports.
cmd/ctr/commands/tasks/tasks_windows.go Update Windows task helpers to v3 command type.
cmd/ctr/commands/tasks/tasks_unix.go Update Unix task helpers to v3 command type and minor IO close handling.
cmd/ctr/commands/tasks/start.go Update start command to v3 action signature and flag/arg access.
cmd/ctr/commands/tasks/resume.go Update resume command to v3 action signature and arg access.
cmd/ctr/commands/tasks/ps.go Update ps command to v3 action signature and arg access.
cmd/ctr/commands/tasks/pause.go Update pause command to v3 action signature and arg access.
cmd/ctr/commands/tasks/metrics.go Update metrics command to v3 action signature and flag access.
cmd/ctr/commands/tasks/list.go Update list command to v3 action signature and flag access.
cmd/ctr/commands/tasks/kill.go Update kill command to v3 action signature and flag access.
cmd/ctr/commands/tasks/exec.go Update exec command to v3 action signature and flag/arg access.
cmd/ctr/commands/tasks/delete.go Update delete command to v3 action signature and arg access.
cmd/ctr/commands/tasks/checkpoint.go Update checkpoint command to v3 action signature and flag access.
cmd/ctr/commands/tasks/attach.go Update attach command to v3 action signature and arg access.
cmd/ctr/commands/shim/pprof.go Update pprof commands to v3 action signature and command tree field name.
cmd/ctr/commands/sandboxes/sandboxes.go Update sandboxes commands to v3 action signature and Commands field.
cmd/ctr/commands/run/run.go Update run command to v3 action signature and flag/arg access.
cmd/ctr/commands/resolver.go Update resolver helpers to accept *cli.Command (v3).
cmd/ctr/commands/plugins/plugins.go Update plugins commands to v3 action signature and output writer usage.
cmd/ctr/commands/oci/oci.go Update oci command tree to v3 action signature and Commands field.
cmd/ctr/commands/namespaces/namespaces.go Update namespaces commands to v3 action signature and Commands field.
cmd/ctr/commands/namespaces/namespaces_other.go Update non-linux delete opts helper signature for v3.
cmd/ctr/commands/namespaces/namespaces_linux.go Update linux delete opts helper (needs v3 type fix).
cmd/ctr/commands/leases/leases.go Update leases commands to v3 action signature and Commands field.
cmd/ctr/commands/install/install.go Update install command to v3 action signature and arg/flag access.
cmd/ctr/commands/info/info.go Update info command to v3 action signature.
cmd/ctr/commands/images/usage.go Update images usage command to v3 action signature and arg access.
cmd/ctr/commands/images/unmount.go Update images unmount command to v3 action signature and writer usage.
cmd/ctr/commands/images/tag.go Update images tag command to v3 action signature and arg/flag access.
cmd/ctr/commands/images/mount.go Update images mount command to v3 action signature and writer usage.
cmd/ctr/commands/images/inspect.go Update images inspect command to v3 action signature and flag access.
cmd/ctr/commands/images/export.go Update images export command to v3 action signature and flag defaults.
cmd/ctr/commands/images/convert.go Update images convert command to v3 action signature and flag defaults.
cmd/ctr/commands/images/build_erofs_cache.go Update erofs cache command to v3 action signature and flag access.
cmd/ctr/commands/events/events.go Update events command to v3 action signature and arg forwarding.
cmd/ctr/commands/deprecations/deprecations.go Update deprecations command to v3 action signature and format handling.
cmd/ctr/commands/content/prune.go Update content prune command to v3 action signature and Commands field.
cmd/ctr/commands/content/fetch.go Update fetch command and config builder to v3 command type.
cmd/ctr/commands/containers/restore.go Update restore command to v3 action signature and flag access.
cmd/ctr/commands/containers/checkpoint.go Update containers checkpoint command to v3 action signature and flag access.
cmd/ctr/commands/commands.go Update common flags and helpers for v3 flag source API.
cmd/ctr/commands/commands_windows.go Update runtime options helper signature for v3.
cmd/ctr/commands/commands_unix.go Update runtime options helper signature and flag access for v3.
cmd/ctr/commands/client.go Update context handling and client creation to accept (ctx, *cli.Command).
cmd/containerd/main.go Update containerd entrypoint to Run(ctx, args) with background context.
cmd/containerd/command/service_windows.go Update Windows service flag plumbing for v3 command type.
cmd/containerd/command/service_unsupported.go Update unsupported service stub for v3 command type.
cmd/containerd/command/publish.go Update publish command to v3 action signature and cmd flag access.
cmd/containerd/command/oci-hook.go Update oci-hook command to v3 action signature and cmd arg access.
cmd/containerd/command/config.go Update config command tree to v3 Commands and action signature.
cmd/containerd-stress/density.go Update stress subcommand to v3 action signature and context-aware logging.
Review details
  • Files reviewed: 69/179 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/gen-manpages/main.go Resolved
Copilot AI review requested due to automatic review settings September 3, 2026 02:18

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings September 3, 2026 02:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The vendored urfave/cli/v3 flag implementations include confirmed deserialization and formatting/deref bugs (slice/map JSON unmarshal targets and timestamp String/Get), which can break runtime flag behavior.

Review details
  • Files reviewed: 69/179 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The PR performs a large-scale CLI framework major-version migration plus broad vendoring changes, which is high risk without full CI/compile validation and targeted manual review.

Review details

Suppressed comments (1)

docs/tracing.md:88

  • The example code calls commands.NewClient(ctx, cmd, ...), but cmd is not defined in this snippet and commands.NewClient is an internal ctr helper (not part of the public containerd Go client API). For a “containerd client” example, this should use containerd.New(...) (and defer client.Close()), otherwise readers can’t reproduce the snippet.
  • Files reviewed: 72/182 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 3, 2026 17:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It is a broad CLI framework major-version migration with extensive call-site churn and vendored dependency changes that should be validated via full integration/CLI behavior testing.

Review details

Suppressed comments (1)

docs/tracing.md:88

  • The example no longer compiles: commands.NewClient(ctx, cmd, ...) requires a *cli.Command, but this snippet doesn't define cmd (and commands.NewClient is a ctr-internal helper). For a containerd Go client example, use containerd.New(..., containerd.WithDialOpts(dialOpts)) and defer client.Close() instead of commands.NewClient/cancel.
  • Files reviewed: 72/182 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 5, 2026 01:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The vendored cli/v3 slice flag deserialization currently unmarshals into a pointer-to-pointer (&i.slice), which can break propagation to the caller’s destination slice and hides JSON parse errors.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 72/182 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

There is at least one confirmed compile-time error (new(cmd.Bool(...))) and a broken suggestion message path where command suggestions are appended as a raw token rather than a “Did you mean …?” hint.

Review details

Suppressed comments (1)

cmd/ctr/commands/run/run_windows.go:189

  • This does not compile: new() expects a type, but cmd.Bool("scrub-logs") is a bool value. Also the intent here appears to be taking the address of the parsed flag value to set *bool.
  • Files reviewed: 69/179 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@thaJeztah

Copy link
Copy Markdown
Member Author

There is at least one confirmed compile-time error (new(cmd.Bool(...))) and a broken suggestion message path where command suggestions are appended as a raw token rather than a “Did you mean …?” hint.

"confirmed" is not really confirmed here, and not even sue what it means with the second part ("a broken suggestion message path").

@thaJeztah thaJeztah added this to the 2.4 milestone Sep 9, 2026
@samuelkarp

Copy link
Copy Markdown
Member

@thaJeztah can you rebase?

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Copilot AI review requested due to automatic review settings September 9, 2026 23:15
@thaJeztah

Copy link
Copy Markdown
Member Author

@samuelkarp done 👍

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Vendored cli/v3 suggestion handling appears to regress user-facing “did you mean” messaging (SuggestCommand returns a raw token rather than a formatted message), which should be corrected before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 69/179 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@mxpv

mxpv commented Sep 10, 2026

Copy link
Copy Markdown
Member

Changes LGTM
The diff is pretty substantial 179 files, +8,906 -10,554
Should we consider this for 2.5 ?

@samuelkarp

Copy link
Copy Markdown
Member

The diff is pretty substantial 179 files, +8,906 -10,554

Most of that is vendor. The actual code changes are all within cmd and are really straightforward.

(If you object to the vendor churn that's one thing, but the actual diffstat is negative.)

@thaJeztah

Copy link
Copy Markdown
Member Author

Yeah, I deliberately made the preparations in a separate PR; #14103 so that this one is really about the v3 bump only.

I'd be OK moving it if we have big concerns; my main motivation was that v2.4 is a good moment to switch (new release), and that most projects in the ecosystem already switched to v3 (so less version sprawl).

(That said; I do like the overall shape of v3, with much clearer / more idiomatic context handling)

@mxpv

mxpv commented Sep 10, 2026

Copy link
Copy Markdown
Member

Ack, let's get this in then.

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Sep 10, 2026
@dmcgowan
dmcgowan added this pull request to the merge queue Sep 10, 2026
@dmcgowan dmcgowan moved this from Review In Progress to Merge on Green in Pull Request Review Sep 10, 2026
Merged via the queue into containerd:main with commit 157bbc9 Sep 10, 2026
95 of 98 checks passed
@github-project-automation github-project-automation Bot moved this from Merge on Green to Done in Pull Request Review Sep 10, 2026
@thaJeztah
thaJeztah deleted the urfave_v3 branch September 10, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants