Skip to content

feat: implement import logic for Zarf Values#4427

Merged
brandtkeller merged 18 commits into
zarf-dev:mainfrom
Racer159:feat/add-values-import
May 6, 2026
Merged

feat: implement import logic for Zarf Values#4427
brandtkeller merged 18 commits into
zarf-dev:mainfrom
Racer159:feat/add-values-import

Conversation

@Racer159
Copy link
Copy Markdown
Contributor

@Racer159 Racer159 commented Dec 3, 2025

Description

This PR implements import logic for Zarf Values.

Related Issue

Fixes #N/A

Checklist before merging

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 3, 2025

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 0cc9fe2
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/69f915864890470008a4f142

@Racer159 Racer159 force-pushed the feat/add-values-import branch from 7f28fcf to 68adc37 Compare December 3, 2025 00:21
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 3, 2025

Codecov Report

❌ Patch coverage is 73.91304% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pkg/packager/layout/assemble.go 25.00% 2 Missing and 1 partial ⚠️
src/pkg/packager/load/import.go 84.21% 3 Missing ⚠️
Files with missing lines Coverage Δ
src/pkg/packager/layout/assemble.go 43.17% <25.00%> (-0.10%) ⬇️
src/pkg/packager/load/import.go 51.96% <84.21%> (+1.47%) ⬆️

... and 1 file with indirect coverage changes

🚀 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.

Signed-off-by: Wayne Starr <[email protected]>
@Racer159 Racer159 marked this pull request as ready for review December 3, 2025 00:38
@Racer159 Racer159 requested review from a team as code owners December 3, 2025 00:38
@mkcp mkcp moved this to PR Review in Zarf Dec 3, 2025
@AustinAbro321
Copy link
Copy Markdown
Member

Overall logic looks good, but worth noting that this PR depends on #4403 as without that change imports will not work since Zarf will look for a values directory.

Comment thread site/src/content/docs/ref/components.mdx Outdated
|----------------------------|--------------------------|-------------|
| 'name'd Globals | `constants`, `variables` | These fields will match on `name` building up a map as components are processed (starting with the importing package definition). Any names that already exist will be skipped so the parent or an earlier component import will take precedence. |
| Un'name'd Primitive Arrays | `files.values` | The importing package definition's array will be appended to the end of the array from the imported component's package definition. Elements will be reappended regardless of whether they already exist in the array (since merge order impacts the final values). |
| Global Behavior | `files.schema` | This field will always take the value of the importing component's package definition (even if it is empty) |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think there is an important decision point here around merging or not merging schemas. It seems like the allOf key could be used here to manage this.

There are a few non-ideal aspects of this strategy:

  • There wouldn't be precedence, the parent wouldn't take priority.
  • The value would have to be valid against every schema. This could lead to values that are impossible to define.

AnyOf, won't work since if any schemas don't define a certain property then it will pass.

Still AllOf could be the way to go. It's a more intuitive experience. Curious if you considered schema merging and ran into any hard blockers

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.

I did briefly consider schema merging - my thoughts though were to basically follow a similar tact to how values files are merged where parent keys would override child keys within the JSON.

This would need to be handled specific to the jsonschema format but for example:

$defs, patternProperties and properties would replace by key so if a parent redefined Constant here it would replace the whole definition under that key:

"Constant": {
but if it was a new key it would just be merged into the map.

Strings in the schema (like $id, additionalProperties, or description) could just take whatever is in the parent.

There could be some other things to think about in there too (like what happens if someone mixed jsonschema versions) but that shouldn't happen since there is really only one non-draft currently published and folks should just use 2020-12 - Zarf maybe could also just hard-require a specific version.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

considering the component-to-package relationship - have we considered namespacing values and nesting the schema?

There is a lot to consider here - so if it has been covered then the current discussion should continue. Otherwise I am curious if it could be a valid alternative to isolate merge collision issues.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Proposal PR for review: zarf-dev/proposals#55

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Namespacing introduced more complexity than we want to pursue so I am not recommending that strategy.

@github-project-automation github-project-automation Bot moved this from PR Review to In progress in Zarf Dec 11, 2025
Co-authored-by: Austin Abro <[email protected]>
Signed-off-by: Wayne Starr <[email protected]>
Copy link
Copy Markdown
Member

@brandtkeller brandtkeller left a comment

Choose a reason for hiding this comment

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

Testdata looks incomplete - or I am missing context.

Comment thread src/pkg/packager/load/testdata/import/variables/zarf.yaml Outdated
Comment thread src/pkg/packager/load/import.go
@brandtkeller
Copy link
Copy Markdown
Member

@Racer159 Can you rebase with main to bring this up-to-date? I want to compare available options but I intend to evaluate any edgecases and otherwise advocate for getting this work merged as-is or similar and then pushing progress thereafter for values maturation.

@Racer159 Racer159 force-pushed the feat/add-values-import branch from b0c61e7 to 9759c49 Compare April 22, 2026 01:48
@brandtkeller
Copy link
Copy Markdown
Member

Updated tests to isolate testing values import and merge behaviors.

I think we should consider UX next:

  • zarf dev inspect ignores imports entirely
  • zarf package inspect lists the files as they would exist on import instead of the aggregate values.yaml that now lives within the package. Should we mutate this for accuracy around the built package or keep it for backwards transparency?

I think any schema decisions should be part of a separate PR. The docs include mention of the behavior now and we can decide if we want to pursue schema import behaviors.

@brandtkeller
Copy link
Copy Markdown
Member

Adding a thought - Looking at package values at the top level you specify values.files[] and this is a list of paths to package values files for the package. Imports will add items to this list.

Once packaged - this list is slightly less representative - we parse all values files and consolidate into a single values.yaml file in the package.

Options that stand out immediately:
Retain them as they are defined or resolved - zarf package inspect will include the declarative definition but the underlying package will only have a values.yaml
mutate the definition so that zarf package create specifies the packaged file values.yaml and not the original definition.

1 feels more correct while 2 feels most accurate (regarding a built package). I do wonder if we should revisit the original design.... I think there is a third route where we don't consolidate internally to a values.yaml that could be most representative of both scenarios.

@AustinAbro321
Copy link
Copy Markdown
Member

I would stay with option 1 after considering the most likely workflows of users.

Users are unlikely to unarchive a package to figure out what is in the values.yaml, and are more likely to run zarf package inspect manifests|values-files. If they get something unexpected, they may run zarf package inspect definition to see which files were included. By removing what the creator wrote, we make it more difficult to view what was used at create time.

Similarly, I would rather compile the files at create time. It's simpler to implement, and while keeping them separate might give higher fidelity to someone viewing an unarchived package, I wouldn't necessarily want to encourage this, and would rather introduce inspect commands if there is that need.

Comment thread src/pkg/packager/load/testdata/import/values/basic/zarf.yaml Outdated
Comment thread src/pkg/packager/load/import.go
Comment thread src/pkg/packager/load/import.go
Comment thread site/src/content/docs/ref/components.mdx
Copy link
Copy Markdown
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.

LGTM, glad to see this in

@brandtkeller brandtkeller added this pull request to the merge queue May 6, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 6, 2026
@brandtkeller brandtkeller added this pull request to the merge queue May 6, 2026
Merged via the queue into zarf-dev:main with commit fde1211 May 6, 2026
32 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in Zarf May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Support transient package values during component import

4 participants