refactor(artifacts): share inspection root metadata lookup (#16758)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-04 22:56:51 +08:00
1 parent 6d3b582215
commit 5e2489e128
1 file changed
+7 -9
+7 -9
View File
@@ -413,6 +413,10 @@ const uniqueOperations = (
index,
);
const rootFormatMetadata = (inventory: ArtifactInventoryResult) =>
inventory.occurrences.find(({ logical_path }) => logical_path === ".")
?.format_metadata;
const formatProbes = (
inventory: ArtifactInventoryResult,
rootImage: ArtifactInspectionRootImage | undefined,
@@ -479,9 +483,7 @@ const formatProbes = (
},
];
if (format === "mcuboot") {
const rootMeta = inventory.occurrences.find(
(row) => row.logical_path === ".",
)?.format_metadata;
const rootMeta = rootFormatMetadata(inventory);
const uncompressed = rootMeta?.kind === "mcuboot" && !rootMeta.compressed;
return uncompressed &&
inventory.occurrences.some(
@@ -514,9 +516,7 @@ const formatProbes = (
const bfltProbes = (
inventory: ArtifactInventoryResult,
): ArtifactInspectionResult["next_probes"] => {
const root = inventory.occurrences.find(
({ logical_path }) => logical_path === ".",
)?.format_metadata;
const root = rootFormatMetadata(inventory);
const text = inventory.occurrences.some(
(row) =>
row.format_metadata?.kind === "bflt-segment" &&
@@ -557,9 +557,7 @@ const zipPackageProbes = (
const espFlashDumpProbes = (
inventory: ArtifactInventoryResult,
): ArtifactInspectionResult["next_probes"] => {
const root = inventory.occurrences.find(
({ logical_path }) => logical_path === ".",
)?.format_metadata;
const root = rootFormatMetadata(inventory);
if (root?.kind !== "esp-image") return [];
const dump = root.flash_dump;
if (dump === null) return [];