From 16b8ab31fb8dce9ece33cf25c20dd3aca71db95f Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 24 Oct 2024 18:16:39 +0000 Subject: [PATCH 1/6] skip schema validation Signed-off-by: Austin Abro --- src/api/v1alpha1/component.go | 2 ++ src/internal/packager/helm/chart.go | 4 ++++ zarf.schema.json | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/src/api/v1alpha1/component.go b/src/api/v1alpha1/component.go index 74ac45251c..f545f92330 100644 --- a/src/api/v1alpha1/component.go +++ b/src/api/v1alpha1/component.go @@ -157,6 +157,8 @@ type ZarfChart struct { ValuesFiles []string `json:"valuesFiles,omitempty"` // [alpha] List of variables to set in the Helm chart. Variables []ZarfChartVariable `json:"variables,omitempty"` + // Prevents Helm from validating the values against the JSON schema. Useful in the airgap when the JSON Schema references the internet. + SkipSchemaValidation bool `json:"skipSchemaValidation,omitempty"` } // ZarfChartVariable represents a variable that can be set for a Helm chart overrides. diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index 954b1d6144..4528da2acf 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -294,6 +294,8 @@ func (h *Helm) installChart(ctx context.Context, postRender *renderer) (*release // Must be unique per-namespace and < 53 characters. @todo: restrict helm loadedChart name to this. client.ReleaseName = h.chart.ReleaseName + client.SkipSchemaValidation = h.chart.SkipSchemaValidation + // Namespace must be specified. client.Namespace = h.chart.Namespace @@ -327,6 +329,8 @@ func (h *Helm) upgradeChart(ctx context.Context, lastRelease *release.Release, p client.SkipCRDs = true + client.SkipSchemaValidation = h.chart.SkipSchemaValidation + // Namespace must be specified. client.Namespace = h.chart.Namespace diff --git a/zarf.schema.json b/zarf.schema.json index 67094c0f38..107125f75e 100644 --- a/zarf.schema.json +++ b/zarf.schema.json @@ -377,6 +377,10 @@ }, "type": "array", "description": "[alpha] List of variables to set in the Helm chart." + }, + "skipSchemaValidation": { + "type": "boolean", + "description": "Prevents Helm from validating the values file against it's JSON schema. Useful in the airgap when the JSON Schema references the internet." } }, "additionalProperties": false, From c322db82859493be84c78b67f9271a82e9701846 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Wed, 30 Oct 2024 15:19:42 +0000 Subject: [PATCH 2/6] update schema Signed-off-by: Austin Abro --- zarf.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zarf.schema.json b/zarf.schema.json index 107125f75e..31065c50d2 100644 --- a/zarf.schema.json +++ b/zarf.schema.json @@ -380,7 +380,7 @@ }, "skipSchemaValidation": { "type": "boolean", - "description": "Prevents Helm from validating the values file against it's JSON schema. Useful in the airgap when the JSON Schema references the internet." + "description": "Prevents Helm from validating the values against the JSON schema. Useful in the airgap when the JSON Schema references the internet." } }, "additionalProperties": false, From 34bcf38a28f15d4354e9c834808ba9d45abac8c3 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Wed, 30 Oct 2024 15:21:52 +0000 Subject: [PATCH 3/6] reword Signed-off-by: Austin Abro --- src/api/v1alpha1/component.go | 2 +- zarf.schema.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/v1alpha1/component.go b/src/api/v1alpha1/component.go index f545f92330..f840e18172 100644 --- a/src/api/v1alpha1/component.go +++ b/src/api/v1alpha1/component.go @@ -157,7 +157,7 @@ type ZarfChart struct { ValuesFiles []string `json:"valuesFiles,omitempty"` // [alpha] List of variables to set in the Helm chart. Variables []ZarfChartVariable `json:"variables,omitempty"` - // Prevents Helm from validating the values against the JSON schema. Useful in the airgap when the JSON Schema references the internet. + // Prevents Helm from validating the values against the JSON schema. Necessary in the air-gap when the JSON Schema references the resources on the internet. SkipSchemaValidation bool `json:"skipSchemaValidation,omitempty"` } diff --git a/zarf.schema.json b/zarf.schema.json index 31065c50d2..8108257fac 100644 --- a/zarf.schema.json +++ b/zarf.schema.json @@ -380,7 +380,7 @@ }, "skipSchemaValidation": { "type": "boolean", - "description": "Prevents Helm from validating the values against the JSON schema. Useful in the airgap when the JSON Schema references the internet." + "description": "Prevents Helm from validating the values against the JSON schema. Necessary in the air-gap when the JSON Schema references the resources on the internet." } }, "additionalProperties": false, From c9af3719c2180b330454ed55307bf17f1f9bbce0 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Wed, 30 Oct 2024 18:46:24 +0000 Subject: [PATCH 4/6] no negatives Signed-off-by: Austin Abro --- src/api/v1alpha1/component.go | 12 ++++++++++-- src/internal/packager/helm/chart.go | 4 ++-- zarf.schema.json | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/api/v1alpha1/component.go b/src/api/v1alpha1/component.go index f840e18172..2337d82161 100644 --- a/src/api/v1alpha1/component.go +++ b/src/api/v1alpha1/component.go @@ -157,8 +157,16 @@ type ZarfChart struct { ValuesFiles []string `json:"valuesFiles,omitempty"` // [alpha] List of variables to set in the Helm chart. Variables []ZarfChartVariable `json:"variables,omitempty"` - // Prevents Helm from validating the values against the JSON schema. Necessary in the air-gap when the JSON Schema references the resources on the internet. - SkipSchemaValidation bool `json:"skipSchemaValidation,omitempty"` + // Whether or not to validate the schema, defaults to true. Necessary in the air-gap when the JSON Schema references resources on the internet. + SchemaValidation *bool `json:"schemaValidation,omitempty"` +} + +// RunSchemaValidation returns if Helm schema validation should be run or not +func (zc ZarfChart) RunSchemaValidation() bool { + if zc.SchemaValidation != nil { + return *zc.SchemaValidation + } + return true } // ZarfChartVariable represents a variable that can be set for a Helm chart overrides. diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index 4528da2acf..5dfce13c0c 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -294,7 +294,7 @@ func (h *Helm) installChart(ctx context.Context, postRender *renderer) (*release // Must be unique per-namespace and < 53 characters. @todo: restrict helm loadedChart name to this. client.ReleaseName = h.chart.ReleaseName - client.SkipSchemaValidation = h.chart.SkipSchemaValidation + client.SkipSchemaValidation = !h.chart.RunSchemaValidation() // Namespace must be specified. client.Namespace = h.chart.Namespace @@ -329,7 +329,7 @@ func (h *Helm) upgradeChart(ctx context.Context, lastRelease *release.Release, p client.SkipCRDs = true - client.SkipSchemaValidation = h.chart.SkipSchemaValidation + client.SkipSchemaValidation = !h.chart.RunSchemaValidation() // Namespace must be specified. client.Namespace = h.chart.Namespace diff --git a/zarf.schema.json b/zarf.schema.json index 8108257fac..da791315ae 100644 --- a/zarf.schema.json +++ b/zarf.schema.json @@ -378,9 +378,9 @@ "type": "array", "description": "[alpha] List of variables to set in the Helm chart." }, - "skipSchemaValidation": { + "schemaValidation": { "type": "boolean", - "description": "Prevents Helm from validating the values against the JSON schema. Necessary in the air-gap when the JSON Schema references the resources on the internet." + "description": "Whether or not to validate the schema, defaults to true. Necessary in the air-gap when the JSON Schema references resources on the internet." } }, "additionalProperties": false, From d0f0674276a21ab2f6cf225d94770607e7f62132 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 31 Oct 2024 13:09:43 +0000 Subject: [PATCH 5/6] rename bool func Signed-off-by: Austin Abro --- src/api/v1alpha1/component.go | 4 ++-- src/internal/packager/helm/chart.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/v1alpha1/component.go b/src/api/v1alpha1/component.go index 2337d82161..9a842ef1d2 100644 --- a/src/api/v1alpha1/component.go +++ b/src/api/v1alpha1/component.go @@ -161,8 +161,8 @@ type ZarfChart struct { SchemaValidation *bool `json:"schemaValidation,omitempty"` } -// RunSchemaValidation returns if Helm schema validation should be run or not -func (zc ZarfChart) RunSchemaValidation() bool { +// ShouldRunSchemaValidation returns if Helm schema validation should be run or not +func (zc ZarfChart) ShouldRunSchemaValidation() bool { if zc.SchemaValidation != nil { return *zc.SchemaValidation } diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index 5dfce13c0c..68914d3d51 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -294,7 +294,7 @@ func (h *Helm) installChart(ctx context.Context, postRender *renderer) (*release // Must be unique per-namespace and < 53 characters. @todo: restrict helm loadedChart name to this. client.ReleaseName = h.chart.ReleaseName - client.SkipSchemaValidation = !h.chart.RunSchemaValidation() + client.SkipSchemaValidation = !h.chart.ShouldRunSchemaValidation() // Namespace must be specified. client.Namespace = h.chart.Namespace @@ -329,7 +329,7 @@ func (h *Helm) upgradeChart(ctx context.Context, lastRelease *release.Release, p client.SkipCRDs = true - client.SkipSchemaValidation = !h.chart.RunSchemaValidation() + client.SkipSchemaValidation = !h.chart.ShouldRunSchemaValidation() // Namespace must be specified. client.Namespace = h.chart.Namespace From 29875a38d3ba1539c3b80387139429ccacbd82a0 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 31 Oct 2024 13:15:55 +0000 Subject: [PATCH 6/6] reword desc Signed-off-by: Austin Abro --- src/api/v1alpha1/component.go | 2 +- zarf.schema.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/v1alpha1/component.go b/src/api/v1alpha1/component.go index 9a842ef1d2..8948f03f5c 100644 --- a/src/api/v1alpha1/component.go +++ b/src/api/v1alpha1/component.go @@ -157,7 +157,7 @@ type ZarfChart struct { ValuesFiles []string `json:"valuesFiles,omitempty"` // [alpha] List of variables to set in the Helm chart. Variables []ZarfChartVariable `json:"variables,omitempty"` - // Whether or not to validate the schema, defaults to true. Necessary in the air-gap when the JSON Schema references resources on the internet. + // Whether or not to validate the values.yaml schema, defaults to true. Necessary in the air-gap when the JSON Schema references resources on the internet. SchemaValidation *bool `json:"schemaValidation,omitempty"` } diff --git a/zarf.schema.json b/zarf.schema.json index da791315ae..9b474b9400 100644 --- a/zarf.schema.json +++ b/zarf.schema.json @@ -380,7 +380,7 @@ }, "schemaValidation": { "type": "boolean", - "description": "Whether or not to validate the schema, defaults to true. Necessary in the air-gap when the JSON Schema references resources on the internet." + "description": "Whether or not to validate the values.yaml schema, defaults to true. Necessary in the air-gap when the JSON Schema references resources on the internet." } }, "additionalProperties": false,