Skip to content

Conversation

@Racer159
Copy link
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

netlify bot commented Dec 3, 2025

Deploy Preview for zarf-docs ready!

Name Link
🔨 Latest commit a2d4f09
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/693b4812cd8f720008044f76
😎 Deploy Preview https://deploy-preview-4427--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.

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

codecov bot commented Dec 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/pkg/packager/load/import.go 51.88% <100.00%> (+1.37%) ⬆️

... and 2 files 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
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.

|----------------------------|--------------------------|-------------|
| '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
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
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
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
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

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

Copy link
Member

Choose a reason for hiding this comment

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

I believe we'll also want sourcePath/targetPath to work with imports with the parents sourcePath/targetPath taking priority

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.

3 participants