Skip to content

completion: add completion for swarm "--filter" flags - #7124

Open
JessThrysoee wants to merge 1 commit into
docker:masterfrom
JessThrysoee:completion-swarm-filters
Open

completion: add completion for swarm "--filter" flags#7124
JessThrysoee wants to merge 1 commit into
docker:masterfrom
JessThrysoee:completion-swarm-filters

Conversation

@JessThrysoee

Copy link
Copy Markdown

The migration to the generated (V2) shell completions dropped the "--filter" key/value suggestions that the legacy bash completion used to provide for the swarm commands, so e.g. "docker service ps --filter " no longer completed anything.

Register filter completions for "docker service ps", "docker service ls", and "docker node ps", following the same approach as the existing completion for "docker events --filter".

@codecov-commenter

codecov-commenter commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The migration to the generated (V2) shell completions dropped the
"--filter" key/value suggestions that the legacy bash completion used to
provide for the swarm commands, so e.g. "docker service ps <service>
--filter <TAB>" no longer completed anything.

Register filter completions for "docker service ps", "docker service
ls", and "docker node ps", following the same approach as the existing
completion for "docker events --filter".

Signed-off-by: Jess Thrysoee <jess@thrysoee.dk>
@JessThrysoee
JessThrysoee force-pushed the completion-swarm-filters branch from e5f6e05 to 89e882a Compare July 26, 2026 13:53
Comment on lines +65 to +66
// Task IDs, names, and labels are not easily discoverable; only offer the key.
return nil, cobra.ShellCompDirectiveNoFileComp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm guessing the old bash-completion couldn't easily do this because the CLI does not have a comment to list tasks, but as a follow up we could look if we actually could use the API client for this;

filter := options.filter.Value()
filter.Add("node", res.Node.ID)
nodeTasks, err := apiClient.TaskList(ctx, client.TaskListOptions{Filters: filter})
if err != nil {
errs = append(errs, err)
continue
}

Definitely OK for a follow-up though, no need to cramp it into this PR.

@JessThrysoee JessThrysoee Jul 26, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

  • label= a TaskList/ServiceList call and pluck the label from the Items
  • name= a little heavier with multiple api calls, should system.taskNames be made available for this?
  • id= probably not as useful, but also just a TaskList call

But I think you are right, this feels like a separate PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yup! No need to do it for this one; I was only glancing over the changes (at a glance they look great! but will have a closer look tomorrow), and was thinking out loud to see if we could fill in the remaining bits.

But indeed; more than fine for a follow-up, so that we can see if it makes sense (outweigh the overhead against how much it improves).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(marked it "unresolved" so that it stays visible, but no need to fix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants