feat: zarf dev schema-generate from existing values#4961
Conversation
Signed-off-by: Wayne Starr <me@racer159.com>
✅ Deploy Preview for zarf-docs canceled.
|
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
Signed-off-by: Wayne Starr <me@racer159.com>
1b1c667 to
6f96560
Compare
Signed-off-by: Wayne Starr <me@racer159.com>
Signed-off-by: Wayne Starr <me@racer159.com>
brandtkeller
left a comment
There was a problem hiding this comment.
initial thoughts around the shape of existing schemas - review WIP
| // Step 3: Generate JSON schema from the final map and save it | ||
| schema := value.GenerateJSONSchema(zarfValues) | ||
|
|
||
| outputFileName := "values.schema.json" |
There was a problem hiding this comment.
Should we also consider the specific defined.Pkg.Values.Schema path?
There was a problem hiding this comment.
Yes we likely should - I'll update to do that (and fallback if there isn't one)
| CachePath: cachePath, | ||
| RemoteOptions: defaultRemoteOptions(), | ||
| } | ||
| defined, err := load.PackageDefinition(ctx, basePath, loadOpts) |
There was a problem hiding this comment.
defined is a DefinedPackage
type DefinedPackage struct {
Pkg v1alpha1.ZarfPackage
ImportedSchemas []string
}
These ImportedSchemas likely need to be merged with the specified schema (or created if not specified) prior to the final resolve workflow.
There was a problem hiding this comment.
I didn't do it but would we want to merge the helm chart schemas in too? I think we would still need the final reconcile at the end based on what we found as "truth" - it is available in helmChart.schema and for those sections will become an enforcement mechanism (so likely best to reencode that in the Zarf schema to fail early?)
Description
This adds a
zarf dev generate-schemacommand to load the Zarf values defaults and then generate an inferred schema from those values. It does this by:values.filesto create an initial default listcomponents[x].chartsvalues.sourcePath andvalues.targetPath` to fill in any missing valuesvaluesFilesor the Helm Chart'svalues.yamlThis also will load an existing schema (if one exists) and reconcile that schema with the inferred types in case the Zarf package creator already has a schema and has added additional keys (such as
description,required, etc).Related Issue
Fixes #4918
Checklist before merging