Skip to content

feat(find-images): 4509 include archives in find image#4551

Draft
chaospuppy wants to merge 18 commits intozarf-dev:mainfrom
chaospuppy:4509-include-archives-in-find-image
Draft

feat(find-images): 4509 include archives in find image#4551
chaospuppy wants to merge 18 commits intozarf-dev:mainfrom
chaospuppy:4509-include-archives-in-find-image

Conversation

@chaospuppy
Copy link
Contributor

@chaospuppy chaospuppy commented Jan 23, 2026

Description

This MR resolves #4509 by doing the following:

  • Allow schema validation to succeed by removing findings related to an empty image list under imageArchives keys. Currently this finding is only removed when calling PackageDefinition from FindImages
  • Add FindImagesInArchive to identify and return all images in imageArchives.path
  • Update unit tests

Related Issue

Fixes #4509

Checklist before merging

@netlify
Copy link

netlify bot commented Jan 23, 2026

Deploy Preview for zarf-docs ready!

Name Link
🔨 Latest commit 41a5d70
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/6997a848d59e280008424972
😎 Deploy Preview https://deploy-preview-4551--zarf-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@chaospuppy
Copy link
Contributor Author

@AustinAbro321 when you have a moment, please take a look. I am still going to update a few unit tests.

@chaospuppy chaospuppy force-pushed the 4509-include-archives-in-find-image branch from aad61df to 6d872f4 Compare January 24, 2026 00:49
@chaospuppy chaospuppy marked this pull request as ready for review January 24, 2026 00:50
@chaospuppy chaospuppy requested review from a team as code owners January 24, 2026 00:50
@chaospuppy chaospuppy force-pushed the 4509-include-archives-in-find-image branch 2 times, most recently from b03b517 to f35514c Compare January 27, 2026 20:43
@chaospuppy chaospuppy changed the title 4509 include archives in find image feat(find-images): 4509 include archives in find image Jan 27, 2026
@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 45.83333% with 39 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pkg/images/unpack.go 39.53% 17 Missing and 9 partials ⚠️
src/pkg/packager/find_images.go 63.63% 5 Missing and 3 partials ⚠️
src/pkg/packager/load/load.go 28.57% 4 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
src/pkg/packager/load/load.go 42.19% <28.57%> (-1.26%) ⬇️
src/pkg/packager/find_images.go 56.63% <63.63%> (+0.15%) ⬆️
src/pkg/images/unpack.go 50.30% <39.53%> (-3.80%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@AustinAbro321 AustinAbro321 left a comment

Choose a reason for hiding this comment

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

Good start! Thanks for taking this on

// It returns a list of images found in the extracted OCI layout.
func FindImagesInArchive(ctx context.Context, imageArchive, destDir string) ([]string, error) {
// Create a temporary directory for extraction
tmpdir, err := utils.MakeTempDir("")
Copy link
Member

Choose a reason for hiding this comment

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

The extraction logic in this block is mostly duplicated. Lets make a common function to de-duplicate it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made a few changes with this in mind

// SkipVersionCheck skips version requirement validation
SkipVersionCheck bool
// SkipImageArchivesImages ignores schema validation errors when imageArchives does not include an images list
SkipEmptyImageArchivesImages bool
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer a strategy where we create a function load.PackageDefinitionNoValidate() then also make a public function load.Validate(). Keep the load.PackageDefinition function this way validation happens by default.

I believe a public validate function could be generally useful for SDK users who might be creating packages without zarf.yaml files, additionally it'll leave more room in the future for more generic solutions if we need to skip validation for a similar reason

Copy link
Contributor Author

@chaospuppy chaospuppy Jan 27, 2026

Choose a reason for hiding this comment

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

I'm happy to make that split still, but our failure was while validating the file itself here, rather than during the validation of v1alpha1.ZarfPackage. Therefore, it wasn't useful for us to delay validation after adding a placeholder image as we previously discussed to the v1alpha1.ZarfPackage.

I could split them and then add some work to change the zarf.ymal on disk to add an empty array there, but that didn't seem like desirable behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively, I could also split out a Validate and ValidateWithoutSchemaValidation (not literally that name, but something like that) and use the later

return nil, fmt.Errorf("failed to unpack image archive %s: %w", archive.Path, err)
}
for _, image := range archiveImages {
matchedImages[image] = true
Copy link
Member

Choose a reason for hiding this comment

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

I think matched images isn't the right construct. Maybe a new field should be added such as archiveImages. One of the goals of find-images is to be able to copy and paste the output into your zarf.yaml. Currently you'd see this output, which would result in trying to pull the image from the internet if you copied and pasted it

2026-01-27 16:38:42 INF looking up cosign artifacts for discovered images count=3

components:
  - name: kiwix-serve
    images:
      - docker.io/library/kiwix-data:local
      - ghcr.io/kiwix/kiwix-serve:3.5.0-2
      - kiwix-data:local

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, good point, I missed the desire to pull images from the image archive on disk after zarf.yaml has been updated with the output of zarf dev find-images. I'll fix that up!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AustinAbro321 to clarify, are you hoping to see images elements expressed in a such as way as to direct Zarf to pull them from the archive, rather than from the internet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I missed your comment before asking, I think I see the answer in #4577

Copy link
Member

Choose a reason for hiding this comment

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

Just went back and clarified #4577 a bit, but just to write here as well, we should no longer include images because they're in an image archive. If they're in both a manifest we should check if the image archive contains that image, then in the output to the user structure it so it's in the image archive, and the user can simply copy and paste.

Copy link
Member

Choose a reason for hiding this comment

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

Image archives functionality should also work with packager.UpdateImages

@github-project-automation github-project-automation bot moved this to In progress in Zarf Jan 27, 2026
@chaospuppy chaospuppy force-pushed the 4509-include-archives-in-find-image branch from 08c339e to 9534ea6 Compare January 31, 2026 01:53
@AustinAbro321
Copy link
Member

Hello @chaospuppy, I reazlied that the behavior I proposed in #4509, didn't really fit the zarf dev find-images command. However, there is still work to be done to get image archives to behave properly for zarf dev find-images. I've created #4577 to track this work. If you're interested, I believe this PR could be adjusted for that issue. LMK if you have any questions.

If you do adjust this PR for #4577, don't worry about validation, assume the given zarf.yaml file is valid

@chaospuppy
Copy link
Contributor Author

chaospuppy commented Feb 6, 2026

@AustinAbro321 Are you thinking about handling validation differently in the near future? Trying to get an understanding for which changes I should back out. I am also happy to keep the validation changes in, including making Validation public and creating PackageDefinitionWithoutValidation.

@AustinAbro321
Copy link
Member

@chaospuppy Very possibly handling validation in the near future yes. I suggest backing out of the validation changes in this PR

chaospuppy and others added 13 commits February 9, 2026 14:22
…eholder images list, add skipimagearchivesimages definition option

Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
…efinitionOption for skipping imagearchives images schema findings

Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
…es output

Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
…dev#4554)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
…-organization group (zarf-dev#4553)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
…ev#4552)

Signed-off-by: Jason Washburn <jason.washburn@gmail.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
…images --update

Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
@chaospuppy chaospuppy force-pushed the 4509-include-archives-in-find-image branch from cc9dbd7 to 7bceaee Compare February 9, 2026 22:22
@chaospuppy chaospuppy marked this pull request as draft February 10, 2026 19:39
// PotentialMatches contains potential container images found by a regex
PotentialMatches []string
// ArchiveImages contains images that are included in Matches, but are provided with an imageArchive
ArchiveImages []string
Copy link
Member

Choose a reason for hiding this comment

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

Not yet doing a full review, as this is in draft, but thinking about the architecture here. I believe we shouldn't change anything in the packager.FindImages function in this PR. This function should be focused on finding images from manifests and charts. The logic for determining which of those images are in an image archive so we can customize the print out should be outside of this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay that makes sense, I'll move imageArchives logic into a separate function that can be used for post-processing the images located in FindImages for find-images.

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

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Images within Image Archives should be found when using zarf dev find-images

3 participants