Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg: add new imagefilter package with an ImageFilter #1015

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Nov 6, 2024

This commit creates a new imagefilter package that can be used
to create a filter for the available images that can be build by
the images library.

Support for prefixes and fnmatch style globbing is available.

This will eventually allows us to do:

$ image-builder --list-images --filter arch:aarch64 --filter type:qcow*
or
$ image-builder --list-images --filter ami

The filtering can be both with or without a prefix, i.e. when doing
a "simple" search all common fields (disro,arch,imageType) are checked
but with a prefix search things can be narrowed down more.

Initially the following prefixes filters are supported:
"distro:" - the distro name, e.g. rhel-9, or fedora*
"arch:" - the architecture, e.g. x86_64
"type": - the image type, e.g. ami, or qcow?
"bootmode": - the bootmode, e.g. "legacy", "uefi", "hybrid"

(Split out from the spike in #997)

@thozza

This comment was marked as outdated.

@mvo5

This comment was marked as outdated.

achilleas-k
achilleas-k previously approved these changes Nov 7, 2024
Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

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

I wasn't sure about the filtering at first because I didn't consider filtering by anything new over the existing distro, arch, and type. Filtering by boot mode is interesting and it makes me wonder how far we can go. We could filter by all sorts of things, some of which might require instantiating the manifest, for example (like, to generate a partition table and check if it contains some property). And now I'm running wild with it and thinking about things like searching for image types that select for certain packages (pre-depsolve).

thozza
thozza previously approved these changes Nov 8, 2024
Copy link
Member

@thozza thozza left a comment

Choose a reason for hiding this comment

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

The implementation looks good, and I like that it opens many possibilities for filtering. I've added one comment, which is more of a personal coding style preference. Feel free to resolve it if you don't find it helpful.

pkg/imagefilter/filter.go Outdated Show resolved Hide resolved
@mvo5 mvo5 dismissed stale reviews from thozza and achilleas-k via 01d576a November 8, 2024 15:03
@mvo5 mvo5 requested review from achilleas-k and thozza November 8, 2024 15:05
Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

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

Neat!

Copy link
Member

@thozza thozza left a comment

Choose a reason for hiding this comment

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

Nice 👍

This commit creates a new `imagefilter` package that can be used
to create a filter for the available images that can be build by
the images library.

Support for prefixes and fnmatch style globbing is available.

This will eventually allows us to do:
```
$ image-builder --list-images --filter arch:aarch64 --filter type:qcow*
or
$ image-builder --list-images --filter ami
```

The filtering can be both with or without a prefix, i.e. when doing
a "simple" search all common fields (disro,arch,imageType) are checked
but with a prefix search things can be narrowed down more.

Initially the following prefixes filters are supported:
"distro:" - the distro name, e.g. rhel-9, or fedora*
"arch:" - the architecture, e.g. x86_64
"type": - the image type, e.g. ami, or qcow?
"bootmode": - the bootmode, e.g. "legacy", "uefi", "hybrid"

(Split out from the spike in osbuild#997)
@thozza thozza enabled auto-merge November 8, 2024 16:59
@thozza thozza added this pull request to the merge queue Nov 11, 2024
Merged via the queue into osbuild:main with commit 9ca1cea Nov 11, 2024
19 checks passed
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 18, 2024
This commit adds the new `ibuilder` binary (name still a bit TBD but
this is the best so far IMHO). This binary is meant to build images
from the CLI without the need to setup a daemon. The main use-case
is CI/CD and admins running this in scripts or ad-hoc. The CLI
should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 20, 2024
This commit adds the new `image-builder` binary. This binary is
meant to build images from the CLI without the need to setup a
daemon. The main use-case is CI/CD and admins running this in
scripts or ad-hoc. The CLI should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 21, 2024
This commit adds the new `image-builder` binary. This binary is
meant to build images from the CLI without the need to setup a
daemon. The main use-case is CI/CD and admins running this in
scripts or ad-hoc. The CLI should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 21, 2024
This commit adds the new `image-builder` binary. This binary is
meant to build images from the CLI without the need to setup a
daemon. The main use-case is CI/CD and admins running this in
scripts or ad-hoc. The CLI should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 27, 2024
This commit adds the new `image-builder` binary. This binary is
meant to build images from the CLI without the need to setup a
daemon. The main use-case is CI/CD and admins running this in
scripts or ad-hoc. The CLI should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
mvo5 added a commit to mvo5/image-builder-cli that referenced this pull request Nov 27, 2024
This commit adds the new `image-builder` binary. This binary is
meant to build images from the CLI without the need to setup a
daemon. The main use-case is CI/CD and admins running this in
scripts or ad-hoc. The CLI should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
github-merge-queue bot pushed a commit to osbuild/image-builder-cli that referenced this pull request Nov 28, 2024
This commit adds the new `image-builder` binary. This binary is
meant to build images from the CLI without the need to setup a
daemon. The main use-case is CI/CD and admins running this in
scripts or ad-hoc. The CLI should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see osbuild/images#1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants