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

imagefilter: add ResultFormatter type to support flexible output #1019

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Nov 7, 2024

This commit adds a new ResultFormatter interface that supports
outputing the results as text or JSON.

(this is another splitout from #997)

Name string `json:"name"`
}

type filteredResultJSON struct {
Copy link
Contributor Author

@mvo5 mvo5 Nov 7, 2024

Choose a reason for hiding this comment

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

We need to decide a bit how much we want to expose here, it will become an API so I started very minimal, I played with this a bit and added everything in 37c0921 just to see what it would look like. The result is something like:

{
    "distro": {
      "name": "rhel-10.0",
      "Codename": "",
      "Releasever": "10",
      "OsVersion": "10.0",
      "ModulePlatformID": "platform:el10",
      "Product": "Red Hat Enterprise Linux",
      "OSTreeRef": "rhel/10/%s/edge"
    },
    "arch": {
      "name": "x86_64"
    },
    "image_type": {
      "name": "vmdk",
      "bootmode": "hybrid",
      "filename": "disk.vmdk",
      "MIMEType": "application/x-vmdk",
      "OSTreeRef": "",
      "ISOLabel": "",
      "Size": 1,
      "PartitionType": "gpt",
      "BuildPipelines": [
        "build"
      ],
      "PayloadPipelines": [
        "os",
        "image",
        "vmdk"
      ],
      "PayloadPackageSets": [
        "blueprint"
      ],
      "Exports": [
        "vmdk"
      ]
    }
  },
  {
    "distro": {
      "name": "rhel-10.0",
      "Codename": "",
      "Releasever": "10",
      "OsVersion": "10.0",
      "ModulePlatformID": "platform:el10",
      "Product": "Red Hat Enterprise Linux",
      "OSTreeRef": "rhel/10/%s/edge"
    },
    "arch": {
      "name": "x86_64"
    },
    "image_type": {
      "name": "wsl",
      "bootmode": "none",
      "filename": "disk.tar.gz",
      "MIMEType": "application/x-tar",
      "OSTreeRef": "",
      "ISOLabel": "",
      "Size": 1,
      "PartitionType": "",
      "BuildPipelines": [
        "build"
      ],
      "PayloadPipelines": [
        "os",
        "archive"
      ],
      "PayloadPackageSets": [
        "blueprint"
      ],
      "Exports": [
        "archive"
      ]
    }
  }

...

(just to give a flavor what is there)

[edit: fixed a bug in the generation]

Copy link
Member

Choose a reason for hiding this comment

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

Add a few config parameters and package lists to this and we have a good way to "dump" image definitions in a portable way ^_^

@mvo5 mvo5 force-pushed the imagefilter-fmt branch 2 times, most recently from f574956 to 21b1ec1 Compare November 11, 2024 10:00
This commit adds a new `ResultFormatter` interface that supports
outputing the results as text or JSON.

Note that the text output should be copy/paste friendly, i.e. the
"image-builder" cmdline (or other consuemrs) should support:
```
$ image-builder manifest centos-9 type:qcow2 arch:s390
$ image-builder build centos-9 type:qcow2 arch:x86_64
```
(and of course `build` will need to error there is an architecture
 mistach like host-arch != target-arch).
@mvo5 mvo5 requested review from achilleas-k and thozza November 11, 2024 10:59
@mvo5 mvo5 marked this pull request as ready for review November 11, 2024 10:59
@achilleas-k achilleas-k added this pull request to the merge queue Nov 12, 2024
Merged via the queue into osbuild:main with commit abb3328 Nov 12, 2024
19 checks passed
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.

2 participants