Skip to content

Added command for image inspect#355

Merged
yockgen merged 3 commits intomainfrom
inspect-cmd
Jan 22, 2026
Merged

Added command for image inspect#355
yockgen merged 3 commits intomainfrom
inspect-cmd

Conversation

@magerstam
Copy link
Copy Markdown
Contributor

@magerstam magerstam commented Jan 21, 2026

Merge Checklist

All boxes should be checked before merging the PR

  • The changes in the PR have been built and tested
  • Ready to merge

Description

This PR adds a command in os-image-composer to inspect a RAW
OS image file and displays output in the desired format. Supported formats are currently

os-image-composer inspect --format=json --pretty <IMAGE_FILE>
os-image-composer inspect --format=text <IMAGE_FILE>
os-image-composer inspect --format=yaml <IMAGE_FILE>
./os-image-composer inspect --format=yaml edge-readonly-rt-3.0.20260113.2053.raw 
2026-01-20T19:31:46.453-0800    INFO    os-image-composer/main.go:183   Using configuration from: os-image-composer.yml
2026-01-20T19:31:46.454-0800    INFO    os-image-composer/inspect_cmd.go:67     Inspecting image file: edge-readonly-rt-3.0.20260113.2053.raw
file: edge-readonly-rt-3.0.20260113.2053.raw
sizebytes: 4294967296
partitiontable:
    type: gpt
    logicalsectorsize: 512
    physicalsectorsize: 512
    protectivembr: true
    partitions:
        - index: 1
          name: esp
          type: C12A7328-F81F-11D2-BA4B-00A0C93EC93B
          startlba: 2048
          endlba: 786431
          sizebytes: 401604608
          flags: "0"
          logicalSectorSize: 512
          filesystem:
            type: vfat
            label: NO NAME
            uuid: 3ff6e060
            notes:
                - 'diskfs GetFilesystem(1) failed: unknown filesystem on partition 1'
            fatType: FAT16
            bytesPerSector: 512
            sectorsPerCluster: 16
            clusterCount: 48994
            hasUki: true
            peEvidence:
                - path: EFI/BOOT/BOOTX64.EFI
                  size: 99328
                  sha256: 29fbbd603d29cc782a725f06bd576b74352dc1ee0f357c6d306d6764c7beaa36
                  arch: x86_64
                  kind: unknown
                  hasSbat: true
                  sections:
                    - .text
                    - .rodata
                    - .data
                    - .sbat
                    - .sdmagic
                    - .osrel
                    - .reloc
                  osReleaseRaw: |-
                    ID=systemd-boot
                    VERSION="255-31.emt3"
                    NAME="systemd-boot 255-31.emt3"
                  osRelease:
                    ID: systemd-boot
                    NAME: systemd-boot 255-31.emt3
                    VERSION: 255-31.emt3
                  osReleaseSorted:
                    - key: ID
                      value: systemd-boot
                    - key: NAME
                      value: systemd-boot 255-31.emt3
                    - key: VERSION
                      value: 255-31.emt3
                  sectionSha256:
                    .data: c6027c9eafb116a2fe079de03a3226cebabc86871f07f25caab6f060a9aa738c
                    .osrel: 1b86f43c28a31d42e8dfc094e44ade1a257c592c90cba5acf1af8a5c76835a7d
                    .reloc: 3a17527e7f3194d9e847f4f01a540b5672302efa419df1b0630b4b17c5516019
                    .rodata: f984f92ff6b2e79e7c21b8621d72c10c016efb4865515d008b1efb6ab85c530c
                    .sbat: af47c71fca22c74a31a548021aff6326e82ad8d2a7cf1131e55e354fb873ecdb
                    .sdmagic: ceb5d068dab4630f9daf0d1e468c90dd1aa4c233c71169d8b7c52786624c098b
                    .text: c67b0879d4049ffdc1c68ffde55759341fb5b4053321294ea4d675c37ad4cf87
                  osrelSha256: 1b86f43c28a31d42e8dfc094e44ade1a257c592c90cba5acf1af8a5c76835a7d
                - path: EFI/BOOT/grubx64.efi
                  size: 99328
                  sha256: 29fbbd603d29cc782a725f06bd576b74352dc1ee0f357c6d306d6764c7beaa36
                  arch: x86_64
                  kind: grub
                  hasSbat: true
                  sections:
                    - .text
                    - .rodata
                    - .data
                    - .sbat
                    - .sdmagic
                    - .osrel
                    - .reloc
                  osReleaseRaw: |-
                    ID=systemd-boot
                    VERSION="255-31.emt3"
                    NAME="systemd-boot 255-31.emt3"
                  osRelease:
                    ID: systemd-boot
                    NAME: systemd-boot 255-31.emt3
                    VERSION: 255-31.emt3
                  osReleaseSorted:
                    - key: ID
                      value: systemd-boot
                    - key: NAME
                      value: systemd-boot 255-31.emt3
                    - key: VERSION
                      value: 255-31.emt3
                  sectionSha256:
                    .data: c6027c9eafb116a2fe079de03a3226cebabc86871f07f25caab6f060a9aa738c
                    .osrel: 1b86f43c28a31d42e8dfc094e44ade1a257c592c90cba5acf1af8a5c76835a7d
                    .reloc: 3a17527e7f3194d9e847f4f01a540b5672302efa419df1b0630b4b17c5516019
                    .rodata: f984f92ff6b2e79e7c21b8621d72c10c016efb4865515d008b1efb6ab85c530c
                    .sbat: af47c71fca22c74a31a548021aff6326e82ad8d2a7cf1131e55e354fb873ecdb
                    .sdmagic: ceb5d068dab4630f9daf0d1e468c90dd1aa4c233c71169d8b7c52786624c098b
                    .text: c67b0879d4049ffdc1c68ffde55759341fb5b4053321294ea4d675c37ad4cf87
                  osrelSha256: 1b86f43c28a31d42e8dfc094e44ade1a257c592c90cba5acf1af8a5c76835a7d
                - path: EFI/Linux/linux-6.12.61-2.emt3.efi
                  size: 46368256
                  sha256: 8b7da468ba5cff1a1963c3b94d4b501ef1da0ae23ffeb459c29f1608e4e8e19b
                  arch: x86_64
                  kind: uki
                  hasSbat: true
                  sections:
                    - .text
                    - .rodata
                    - .data
                    - .sbat
                    - .sdmagic
                    - .reloc
                    - .osrel
                    - .cmdline
                    - .uname
                    - .initrd
                    - .linux
                  isUki: true
                  cmdline: root=/dev/mapper/rootfs_verity boot_uuid=926c7e7a-f917-4c1e-8893-e394bc08eef2 security=selinux selinux=1 lockdown=integrity quiet splash idle=poll sysctl.vm.overcommit_memory=1 sysctl.kernel.panic=10 sysctl.kernel.panic_on_oops=1 sysctl.fs.inotify.max_user_instances=8192 rd.shell=0 rd.timeout=200 rd.emergency=reboot i915.force_probe=*
                  uname: 6.12.61-2.emt3
                  osReleaseRaw: |-
                    NAME="Edge Microvisor Toolkit"
                    VERSION="25.06.01"
                    ID="Edge Microvisor Toolkit"
                    VERSION_ID="3.0"
                    PRETTY_NAME="Edge Microvisor Toolkit 25.06.01"
                    ANSI_COLOR="1;34"
                    HOME_URL="https://github.com/open-edge-platform/edge-microvisor-toolkit"
                    BUG_REPORT_URL="https://github.com/open-edge-platform/edge-microvisor-toolkit"
                    SUPPORT_URL="https://github.com/open-edge-platform/edge-microvisor-toolkit"
                  osRelease:
                    ANSI_COLOR: 1;34
                    BUG_REPORT_URL: https://github.com/open-edge-platform/edge-microvisor-toolkit
                    HOME_URL: https://github.com/open-edge-platform/edge-microvisor-toolkit
                    ID: Edge Microvisor Toolkit
                    NAME: Edge Microvisor Toolkit
                    PRETTY_NAME: Edge Microvisor Toolkit 25.06.01
                    SUPPORT_URL: https://github.com/open-edge-platform/edge-microvisor-toolkit
                    VERSION: 25.06.01
                    VERSION_ID: "3.0"
                  osReleaseSorted:
                    - key: ANSI_COLOR
                      value: 1;34
                    - key: BUG_REPORT_URL
                      value: https://github.com/open-edge-platform/edge-microvisor-toolkit
                    - key: HOME_URL
                      value: https://github.com/open-edge-platform/edge-microvisor-toolkit
                    - key: ID
                      value: Edge Microvisor Toolkit
                    - key: NAME
                      value: Edge Microvisor Toolkit
                    - key: PRETTY_NAME
                      value: Edge Microvisor Toolkit 25.06.01
                    - key: SUPPORT_URL
                      value: https://github.com/open-edge-platform/edge-microvisor-toolkit
                    - key: VERSION
                      value: 25.06.01
                    - key: VERSION_ID
                      value: "3.0"
                  sectionSha256:
                    .cmdline: bab07907d0fa4ae320eb57581be667f1779406e78f8e1396af1115281c145b37
                    .data: bc05db3221a8df65ce1105c6622612f7a7952d832c8192b1f9ce367fbbf9df68
                    .initrd: 1b67a81ced26c5bf7cb21ab1e7fa2c17694658886ad5505083239b8bdc0afb61
                    .linux: a8a1cc0ff8a6bf0d61c321d779d91342953a48922ce6e35e120da48ac65611d8
                    .osrel: ef8c9c1cb6baa685259c5a40a5fa36240506ac6e3174105b9f5ac9f74ffaa4ba
                    .reloc: 876315ed1ed6109392f80763fe9e3b81f082fb5cea111f1d2560c71cba6be4c8
                    .rodata: 1677e8732c1e9df6d4e487d649c106d0adbb3f72cff04d182c07fb13a13500a7
                    .sbat: 73e42b0e422ca7ba607a93138f28e974958d1eeb7a74fe24d3e227220ff1bd8c
                    .sdmagic: ae1462cd6d1fec4304a08bf2494943fc11ba705903271841f3a700a0317d1f03
                    .text: 0126490e25ab49aea3988e55408268803943f72d0c238caa8f2fdac287db4384
                    .uname: 7b56c6c99eba44d249c7b1f83ef70167109a0f23047ed890588ac3a930e2151c
                  kernelSha256: a8a1cc0ff8a6bf0d61c321d779d91342953a48922ce6e35e120da48ac65611d8
                  initrdSha256: 1b67a81ced26c5bf7cb21ab1e7fa2c17694658886ad5505083239b8bdc0afb61
                  cmdlineSha256: bab07907d0fa4ae320eb57581be667f1779406e78f8e1396af1115281c145b37
                  osrelSha256: ef8c9c1cb6baa685259c5a40a5fa36240506ac6e3174105b9f5ac9f74ffaa4ba
                  unameSha256: 7b56c6c99eba44d249c7b1f83ef70167109a0f23047ed890588ac3a930e2151c
        - index: 2
          name: rootfs
          type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
          startlba: 786432
          endlba: 7340031
          sizebytes: 3355443200
          flags: "0"
          logicalSectorSize: 512
          filesystem:
            type: ext4
            uuid: 926c7e7a-f917-4c1e-8893-e394bc08eef2
            blockSize: 4096
            features:
                - has_journal
                - dir_index
                - extents
                - 64bit
                - huge_file
                - meta_bg
        - index: 3
          name: edge_persistent
          type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
          startlba: 7340032
          endlba: 8386559
          sizebytes: 535822336
          flags: "0"
          logicalSectorSize: 512
          filesystem:
            type: ext4
            uuid: 9c3455ac-5017-4977-ae47-c8fdfc80ae63
            blockSize: 4096
            features:
                - has_journal
                - dir_index
                - extents
                - 64bit
                - huge_file
                - meta_bg

The flag pretty uses JSON indentation properly and omitting the flag will print raw JSON without tabs.

./os-image-composer inspect --format=json --pretty edge-readonly-rt-3.0.20260113.2053.raw 
2026-01-20T19:33:01.246-0800    INFO    os-image-composer/main.go:183   Using configuration from: os-image-composer.yml
2026-01-20T19:33:01.246-0800    INFO    os-image-composer/inspect_cmd.go:67     Inspecting image file: edge-readonly-rt-3.0.20260113.2053.raw
{
  "File": "edge-readonly-rt-3.0.20260113.2053.raw",
  "SizeBytes": 4294967296,
  "PartitionTable": {
    "Type": "gpt",
    "LogicalSectorSize": 512,
    "PhysicalSectorSize": 512,
    "ProtectiveMBR": true,
    "Partitions": [
      {
        "Index": 1,
        "Name": "esp",
        "Type": "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
        "StartLBA": 2048,
        "EndLBA": 786431,
        "SizeBytes": 401604608,
        "Flags": "0",
        "logicalSectorSize": 512,
        "filesystem": {
          "type": "vfat",
          "label": "NO NAME",
          "uuid": "3ff6e060",
          "notes": [
            "diskfs GetFilesystem(1) failed: unknown filesystem on partition 1"
          ],
          "fatType": "FAT16",
          "bytesPerSector": 512,
          "sectorsPerCluster": 16,
          "clusterCount": 48994,
          "hasUki": true,
          "peEvidence": [
            {
              "path": "EFI/BOOT/BOOTX64.EFI",
              "size": 99328,
              "sha256": "29fbbd603d29cc782a725f06bd576b74352dc1ee0f357c6d306d6764c7beaa36",
              "arch": "x86_64",
              "kind": "unknown",
              "hasSbat": true,
              "sections": [
                ".text",
                ".rodata",
                ".data",
                ".sbat",
                ".sdmagic",
                ".osrel",
                ".reloc"
              ],
              "osReleaseRaw": "ID=systemd-boot\nVERSION=\"255-31.emt3\"\nNAME=\"systemd-boot 255-31.emt3\"",
              "osRelease": {
                "ID": "systemd-boot",
                "NAME": "systemd-boot 255-31.emt3",
                "VERSION": "255-31.emt3"
              },
              "osReleaseSorted": [
                {
                  "key": "ID",
                  "value": "systemd-boot"
                },
                {
                  "key": "NAME",
                  "value": "systemd-boot 255-31.emt3"
                },
                {
                  "key": "VERSION",
                  "value": "255-31.emt3"
                }
              ],
              "sectionSha256": {
                ".data": "c6027c9eafb116a2fe079de03a3226cebabc86871f07f25caab6f060a9aa738c",
                ".osrel": "1b86f43c28a31d42e8dfc094e44ade1a257c592c90cba5acf1af8a5c76835a7d",
                ".reloc": "3a17527e7f3194d9e847f4f01a540b5672302efa419df1b0630b4b17c5516019",
                ".rodata": "f984f92ff6b2e79e7c21b8621d72c10c016efb4865515d008b1efb6ab85c530c",
                ".sbat": "af47c71fca22c74a31a548021aff6326e82ad8d2a7cf1131e55e354fb873ecdb",
                ".sdmagic": "ceb5d068dab4630f9daf0d1e468c90dd1aa4c233c71169d8b7c52786624c098b",
                ".text": "c67b0879d4049ffdc1c68ffde55759341fb5b4053321294ea4d675c37ad4cf87"
              },
              "osrelSha256": "1b86f43c28a31d42e8dfc094e44ade1a257c592c90cba5acf1af8a5c76835a7d"
            },
            {
              "path": "EFI/BOOT/grubx64.efi",
              "size": 99328,
              "sha256": "29fbbd603d29cc782a725f06bd576b74352dc1ee0f357c6d306d6764c7beaa36",
              "arch": "x86_64",
              "kind": "grub",
              "hasSbat": true,
              "sections": [
                ".text",
                ".rodata",
                ".data",
                ".sbat",
                ".sdmagic",
                ".osrel",
                ".reloc"
              ],
              "osReleaseRaw": "ID=systemd-boot\nVERSION=\"255-31.emt3\"\nNAME=\"systemd-boot 255-31.emt3\"",
              "osRelease": {
                "ID": "systemd-boot",
                "NAME": "systemd-boot 255-31.emt3",
                "VERSION": "255-31.emt3"
              },
              "osReleaseSorted": [
                {
                  "key": "ID",
                  "value": "systemd-boot"
                },
                {
                  "key": "NAME",
                  "value": "systemd-boot 255-31.emt3"
                },
                {
                  "key": "VERSION",
                  "value": "255-31.emt3"
                }
              ],
              "sectionSha256": {
                ".data": "c6027c9eafb116a2fe079de03a3226cebabc86871f07f25caab6f060a9aa738c",
                ".osrel": "1b86f43c28a31d42e8dfc094e44ade1a257c592c90cba5acf1af8a5c76835a7d",
                ".reloc": "3a17527e7f3194d9e847f4f01a540b5672302efa419df1b0630b4b17c5516019",
                ".rodata": "f984f92ff6b2e79e7c21b8621d72c10c016efb4865515d008b1efb6ab85c530c",
                ".sbat": "af47c71fca22c74a31a548021aff6326e82ad8d2a7cf1131e55e354fb873ecdb",
                ".sdmagic": "ceb5d068dab4630f9daf0d1e468c90dd1aa4c233c71169d8b7c52786624c098b",
                ".text": "c67b0879d4049ffdc1c68ffde55759341fb5b4053321294ea4d675c37ad4cf87"
              },
              "osrelSha256": "1b86f43c28a31d42e8dfc094e44ade1a257c592c90cba5acf1af8a5c76835a7d"
            },
            {
              "path": "EFI/Linux/linux-6.12.61-2.emt3.efi",
              "size": 46368256,
              "sha256": "8b7da468ba5cff1a1963c3b94d4b501ef1da0ae23ffeb459c29f1608e4e8e19b",
              "arch": "x86_64",
              "kind": "uki",
              "hasSbat": true,
              "sections": [
                ".text",
                ".rodata",
                ".data",
                ".sbat",
                ".sdmagic",
                ".reloc",
                ".osrel",
                ".cmdline",
                ".uname",
                ".initrd",
                ".linux"
              ],
              "isUki": true,
              "cmdline": "root=/dev/mapper/rootfs_verity boot_uuid=926c7e7a-f917-4c1e-8893-e394bc08eef2 security=selinux selinux=1 lockdown=integrity quiet splash idle=poll sysctl.vm.overcommit_memory=1 sysctl.kernel.panic=10 sysctl.kernel.panic_on_oops=1 sysctl.fs.inotify.max_user_instances=8192 rd.shell=0 rd.timeout=200 rd.emergency=reboot i915.force_probe=*",
              "uname": "6.12.61-2.emt3",
              "osReleaseRaw": "NAME=\"Edge Microvisor Toolkit\"\nVERSION=\"25.06.01\"\nID=\"Edge Microvisor Toolkit\"\nVERSION_ID=\"3.0\"\nPRETTY_NAME=\"Edge Microvisor Toolkit 25.06.01\"\nANSI_COLOR=\"1;34\"\nHOME_URL=\"https://github.com/open-edge-platform/edge-microvisor-toolkit\"\nBUG_REPORT_URL=\"https://github.com/open-edge-platform/edge-microvisor-toolkit\"\nSUPPORT_URL=\"https://github.com/open-edge-platform/edge-microvisor-toolkit\"",
              "osRelease": {
                "ANSI_COLOR": "1;34",
                "BUG_REPORT_URL": "https://github.com/open-edge-platform/edge-microvisor-toolkit",
                "HOME_URL": "https://github.com/open-edge-platform/edge-microvisor-toolkit",
                "ID": "Edge Microvisor Toolkit",
                "NAME": "Edge Microvisor Toolkit",
                "PRETTY_NAME": "Edge Microvisor Toolkit 25.06.01",
                "SUPPORT_URL": "https://github.com/open-edge-platform/edge-microvisor-toolkit",
                "VERSION": "25.06.01",
                "VERSION_ID": "3.0"
              },
              "osReleaseSorted": [
                {
                  "key": "ANSI_COLOR",
                  "value": "1;34"
                },
                {
                  "key": "BUG_REPORT_URL",
                  "value": "https://github.com/open-edge-platform/edge-microvisor-toolkit"
                },
                {
                  "key": "HOME_URL",
                  "value": "https://github.com/open-edge-platform/edge-microvisor-toolkit"
                },
                {
                  "key": "ID",
                  "value": "Edge Microvisor Toolkit"
                },
                {
                  "key": "NAME",
                  "value": "Edge Microvisor Toolkit"
                },
                {
                  "key": "PRETTY_NAME",
                  "value": "Edge Microvisor Toolkit 25.06.01"
                },
                {
                  "key": "SUPPORT_URL",
                  "value": "https://github.com/open-edge-platform/edge-microvisor-toolkit"
                },
                {
                  "key": "VERSION",
                  "value": "25.06.01"
                },
                {
                  "key": "VERSION_ID",
                  "value": "3.0"
                }
              ],
              "sectionSha256": {
                ".cmdline": "bab07907d0fa4ae320eb57581be667f1779406e78f8e1396af1115281c145b37",
                ".data": "bc05db3221a8df65ce1105c6622612f7a7952d832c8192b1f9ce367fbbf9df68",
                ".initrd": "1b67a81ced26c5bf7cb21ab1e7fa2c17694658886ad5505083239b8bdc0afb61",
                ".linux": "a8a1cc0ff8a6bf0d61c321d779d91342953a48922ce6e35e120da48ac65611d8",
                ".osrel": "ef8c9c1cb6baa685259c5a40a5fa36240506ac6e3174105b9f5ac9f74ffaa4ba",
                ".reloc": "876315ed1ed6109392f80763fe9e3b81f082fb5cea111f1d2560c71cba6be4c8",
                ".rodata": "1677e8732c1e9df6d4e487d649c106d0adbb3f72cff04d182c07fb13a13500a7",
                ".sbat": "73e42b0e422ca7ba607a93138f28e974958d1eeb7a74fe24d3e227220ff1bd8c",
                ".sdmagic": "ae1462cd6d1fec4304a08bf2494943fc11ba705903271841f3a700a0317d1f03",
                ".text": "0126490e25ab49aea3988e55408268803943f72d0c238caa8f2fdac287db4384",
                ".uname": "7b56c6c99eba44d249c7b1f83ef70167109a0f23047ed890588ac3a930e2151c"
              },
              "kernelSha256": "a8a1cc0ff8a6bf0d61c321d779d91342953a48922ce6e35e120da48ac65611d8",
              "initrdSha256": "1b67a81ced26c5bf7cb21ab1e7fa2c17694658886ad5505083239b8bdc0afb61",
              "cmdlineSha256": "bab07907d0fa4ae320eb57581be667f1779406e78f8e1396af1115281c145b37",
              "osrelSha256": "ef8c9c1cb6baa685259c5a40a5fa36240506ac6e3174105b9f5ac9f74ffaa4ba",
              "unameSha256": "7b56c6c99eba44d249c7b1f83ef70167109a0f23047ed890588ac3a930e2151c"
            }
          ]
        }
      },
      {
        "Index": 2,
        "Name": "rootfs",
        "Type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
        "StartLBA": 786432,
        "EndLBA": 7340031,
        "SizeBytes": 3355443200,
        "Flags": "0",
        "logicalSectorSize": 512,
        "filesystem": {
          "type": "ext4",
          "uuid": "926c7e7a-f917-4c1e-8893-e394bc08eef2",
          "blockSize": 4096,
          "features": [
            "has_journal",
            "dir_index",
            "extents",
            "64bit",
            "huge_file",
            "meta_bg"
          ]
        }
      },
      {
        "Index": 3,
        "Name": "edge_persistent",
        "Type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
        "StartLBA": 7340032,
        "EndLBA": 8386559,
        "SizeBytes": 535822336,
        "Flags": "0",
        "logicalSectorSize": 512,
        "filesystem": {
          "type": "ext4",
          "uuid": "9c3455ac-5017-4977-ae47-c8fdfc80ae63",
          "blockSize": 4096,
          "features": [
            "has_journal",
            "dir_index",
            "extents",
            "64bit",
            "huge_file",
            "meta_bg"
          ]
        }
      }
    ]
  }
}

Unit tests was added to cover the command with fake interface to the imageinspect in places required to better cover the code base thoroughly.

Any Newly Introduced Dependencies

How Has This Been Tested?

Unit-tests passes

@magerstam magerstam requested review from arodage, Copilot and yockgen and removed request for Copilot January 21, 2026 03:23
@magerstam magerstam added the enhancement New feature or request label Jan 21, 2026
@magerstam magerstam requested a review from Copilot January 21, 2026 03:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an inspect command to os-image-composer for analyzing RAW OS image files. The command supports multiple output formats (text, JSON, YAML) with optional JSON pretty-printing.

Changes:

  • Added new inspect subcommand with support for text, JSON, and YAML output formats
  • Enhanced OS release information parsing to return sorted key-value pairs for deterministic output
  • Updated text renderer to display parsed OS release data in a structured format with fallback to raw output

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cmd/os-image-composer/main.go Registered the new inspect command
cmd/os-image-composer/inspect_cmd.go Implements the inspect command with format validation and output rendering
cmd/os-image-composer/inspect_cmd_test.go Comprehensive unit tests for the inspect command using fake inspector
internal/image/imageinspect/imageinspect.go Added KeyValue type and OSReleaseSorted field; updated DisplaySummary signature
internal/image/imageinspect/bootloader_pe.go Modified parseOSRelease to return both map and sorted key-value pairs
internal/image/imageinspect/imageinspect_core_test.go Updated test to handle new parseOSRelease return signature
internal/image/imageinspect/renderer_text.go Added printOSReleaseKV function and updated PrintSummary to use sorted OS release data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/os-image-composer/inspect_cmd.go Outdated
Comment thread cmd/os-image-composer/inspect_cmd_test.go
magerstam and others added 2 commits January 20, 2026 19:28
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@yockgen yockgen merged commit b378cce into main Jan 22, 2026
18 checks passed
Comment thread cmd/os-image-composer/inspect_cmd.go
if err != nil {
return fmt.Errorf("marshal json: %w", err)
}
_, _ = fmt.Fprintln(out, string(b))
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.

erros ignored

imageinspect.PrintSummary(out, summary)
return nil

case "json":
Copy link
Copy Markdown
Contributor

@arodage arodage Jan 22, 2026

Choose a reason for hiding this comment

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

Suggested change
case "json":
case "json":
enc := json.NewEncoder(out)
if pretty {
enc.SetIndent("", " ")
}
if err := enc.Encode(summary); err != nil {
return fmt.Errorf("encode json: %w", err)
}
return nil

@arodage
Copy link
Copy Markdown
Contributor

arodage commented Jan 22, 2026

In ADR we mentnioed --output flag.
Can be added later.


// createInspectCommand creates the inspect subcommand
func createInspectCommand() *cobra.Command {
validateCmd := &cobra.Command{
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.

variable name is confusing:

Suggested change
validateCmd := &cobra.Command{
inspectCmd := &cobra.Command{

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will address, thank you!

newInspector = func() inspector {
return &fakeInspector{err: errors.New("boom")}
}
defer resetInspectFlags()
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.

This defer is redundant since t.Cleanup(resetInspectFlags above already handles cleanup after the test completes.

}
}

defer resetInspectFlags()
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.

This defer is redundant since t.Cleanup(resetInspectFlags above already handles cleanup after the test completes.

Copy link
Copy Markdown
Contributor

@arodage arodage left a comment

Choose a reason for hiding this comment

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

Added minor comments can be addressed later in next PR

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants