Skip to content

history: add filters to ls - #3091

Merged
tonistiigi merged 2 commits into
docker:masterfrom
tonistiigi:history-filters
Apr 8, 2025
Merged

tonistiigi merged 2 commits into
docker:masterfrom
tonistiigi:history-filters

Conversation

@tonistiigi

Copy link
Copy Markdown
Member

Adds --filter and --local to history ls. Filters are "docker-style" with = and != separators and less-than and greater-than for time fields.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
|:----------------|:--------------|:--------|:---------------------------------------------|
| `--builder` | `string` | | Override the configured builder instance |
| `-D`, `--debug` | `bool` | | Enable debug logging |
| `--filter` | `stringArray` | | Provide filter values (e.g., `status=error`) |

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.

As follow-up we should document the available filters with some examples similar to https://docs.docker.com/reference/cli/docker/container/ls/#filter

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.

Ah found pr description we could grab in the docs: moby/buildkit#5705 (comment)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note that separators are different. BuildKit uses containerd style while buildx uses docker style.

Comment thread commands/history/utils.go
if key == "status" {
return recValue == value
}
return strings.Contains(recValue, value)

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 surprised we don't have an operator for "contains" with docker filters like ~ and does not contain with !~ (cc @thaJeztah).

Comment thread commands/history/utils.go
Comment on lines +275 to +278
if key == "status" {
sep = "=="
} else {
sep = "~="

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.

Ah ok I see we set it here after valueFiler matching moby/buildkit#5705 (comment)

@tonistiigi
tonistiigi merged commit d80ece5 into docker:master Apr 8, 2025
@tonistiigi

Copy link
Copy Markdown
Member Author

@crazy-max Would it make sense to add --local to all the other history commands as well? Eg. docker buildx logs --local "^1"

@crazy-max

crazy-max commented Apr 8, 2025 •

Copy link
Copy Markdown
Member

@crazy-max Would it make sense to add --local to all the other history commands as well? Eg. docker buildx logs --local "^1"

Hum indeed I wonder if this should be a global one then: buildx history --local logs "^1"

Edit:

if this should be a global one then

Nevermind a global one would not make sense for some subcommands like trace

@tonistiigi

Copy link
Copy Markdown
Member Author

Nevermind a global one would not make sense for some subcommands like trace

Why not? It wouldn't make sense for import though, and maybe more commands in the future.

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.

2 participants