diff --git a/docs/3-create-a-zarf-package/4-zarf-schema.md b/docs/3-create-a-zarf-package/4-zarf-schema.md index 8962ec9fc6..80a989a03b 100644 --- a/docs/3-create-a-zarf-package/4-zarf-schema.md +++ b/docs/3-create-a-zarf-package/4-zarf-schema.md @@ -441,26 +441,6 @@ Must be one of: | **Type** | `object` | | **Additional properties** | [![Any type: allowed](https://img.shields.io/badge/Any%20type-allowed-green)](# "Additional Properties of any type are allowed.") | -
- - Pattern Property .* - -  -
- -:::note -All properties whose name matches the regular expression -```.*``` ([Test](https://regex101.com/?regex=.%2A)) -must respect the following conditions -::: - -| | | -| -------- | -------- | -| **Type** | `string` | - -
-
- diff --git a/hack/.templates/jsonschemaforhumans/section_properties_details.md b/hack/.templates/jsonschemaforhumans/section_properties_details.md index d73ad70bc8..dd02f372c6 100644 --- a/hack/.templates/jsonschemaforhumans/section_properties_details.md +++ b/hack/.templates/jsonschemaforhumans/section_properties_details.md @@ -1,5 +1,5 @@ {% for sub_property in schema.iterate_properties %} - {%- if sub_property.is_additional_properties and not sub_property.is_additional_properties_schema -%} + {%- if sub_property.is_additional_properties and not sub_property.is_additional_properties_schema or sub_property.is_pattern_property -%} {% continue %} {% endif %} @@ -19,7 +19,7 @@ {% filter md_heading(1, html_id, True) -%} {%- filter replace('\n', '') -%} - {%- if sub_property.is_pattern_property %} Pattern Property{% endif %} {% with schema=sub_property %}{%- include "breadcrumbs.md" %} {% endwith %} + {% with schema=sub_property %}{%- include "breadcrumbs.md" %} {% endwith %} {%- if not skip_required and sub_property.property_name -%} {{ "*" if sub_property.is_required_property else "" -}} {%- endif -%} @@ -40,13 +40,6 @@ {% endif %} {% with schema=sub_property, skip_headers=False %} - {% if sub_property.is_pattern_property %} -:::note -All properties whose name matches the regular expression -```{{ sub_property.property_name }}``` ([Test](https://regex101.com/?regex={{ sub_property.property_name | urlencode }})) -must respect the following conditions -::: - {% endif %} {%- if not skip_required and sub_property.property_name -%} {{ md_badge("Required", "red", show_text=False) if sub_property.is_required_property else "" -}} {%- endif -%} diff --git a/hack/.templates/jsonschemaforhumans/tabbed_section.md b/hack/.templates/jsonschemaforhumans/tabbed_section.md index e675cd6d60..5c7d4a4590 100644 --- a/hack/.templates/jsonschemaforhumans/tabbed_section.md +++ b/hack/.templates/jsonschemaforhumans/tabbed_section.md @@ -6,7 +6,7 @@
{% filter md_heading(2, node.html_id) -%} - {% if node.is_pattern_property %}Pattern{% endif %} Property `{% with schema=node %}{%- include "breadcrumbs.md" %}{% endwith %}` + Property `{% with schema=node %}{%- include "breadcrumbs.md" %}{% endwith %}` {%- endfilter %} {% with schema=node, skip_headers=False %} diff --git a/hack/create-zarf-schema.sh b/hack/create-zarf-schema.sh index cede2b69d6..4dd0fabc99 100755 --- a/hack/create-zarf-schema.sh +++ b/hack/create-zarf-schema.sh @@ -3,5 +3,9 @@ # Create the json schema for the zarf.yaml go run main.go internal gen-config-schema > zarf.schema.json +# Adds pattern properties to all definitions to allow for yaml extensions +jq '.definitions |= map_values(. + {"patternProperties": {"^x-": {}}})' zarf.schema.json > temp_zarf.schema.json +mv temp_zarf.schema.json zarf.schema.json + # Create docs from the zarf.yaml JSON schema docker run -v $(pwd):/app -w /app --rm python:3.8-alpine /bin/sh -c "pip install json-schema-for-humans && generate-schema-doc --config-file hack/.templates/jsfh-config.json zarf.schema.json docs/3-create-a-zarf-package/4-zarf-schema.md" diff --git a/src/pkg/packager/lint/lint_test.go b/src/pkg/packager/lint/lint_test.go index 5f81660d32..dcc6488011 100644 --- a/src/pkg/packager/lint/lint_test.go +++ b/src/pkg/packager/lint/lint_test.go @@ -34,13 +34,18 @@ components: ` const goodZarfPackage = ` +x-name: &name good-zarf-package + kind: ZarfPackageConfig metadata: - name: good-zarf-package + name: *name + x-description: Testing good yaml with yaml extension components: - name: baseline required: true + x-foo: bar + ` func readAndUnmarshalYaml[T interface{}](t *testing.T, yamlString string) T { diff --git a/zarf.schema.json b/zarf.schema.json index d849c1b39a..f8e53e98e2 100644 --- a/zarf.schema.json +++ b/zarf.schema.json @@ -35,7 +35,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "DeprecatedZarfComponentScripts": { "properties": { @@ -74,7 +77,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfBuildData": { "required": [ @@ -142,7 +148,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfChart": { "required": [ @@ -203,7 +212,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponent": { "required": [ @@ -308,7 +320,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentAction": { "properties": { @@ -367,7 +382,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentActionDefaults": { "properties": { @@ -401,7 +419,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentActionSet": { "properties": { @@ -441,7 +462,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentActionSetVariable": { "required": [ @@ -475,13 +499,16 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentActionShell": { "properties": { "windows": { "type": "string", - "description": "(default 'powershell') Indicates a preference for the shell to use on Windows systems (note that choosing 'cmd' will turn off migrations like touch -\u003e New-Item)", + "description": "(default 'powershell') Indicates a preference for the shell to use on Windows systems (note that choosing 'cmd' will turn off migrations like touch -> New-Item)", "examples": [ "powershell", "cmd", @@ -515,7 +542,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentActionWait": { "properties": { @@ -531,7 +561,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentActionWaitCluster": { "required": [ @@ -552,7 +585,7 @@ "description": "The name of the resource or selector to wait for", "examples": [ "podinfo", - "app\u0026#61;podinfo" + "app=podinfo" ] }, "namespace": { @@ -569,7 +602,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentActionWaitNetwork": { "required": [ @@ -604,7 +640,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentActions": { "properties": { @@ -623,7 +662,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentExtensions": { "properties": { @@ -634,7 +676,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentImport": { "properties": { @@ -653,7 +698,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentOnlyCluster": { "properties": { @@ -674,7 +722,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfComponentOnlyTarget": { "properties": { @@ -698,7 +749,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfContainerTarget": { "required": [ @@ -716,7 +770,7 @@ "type": "string", "description": "The K8s selector to target for data injection", "examples": [ - "app\u0026#61;data-injection" + "app=data-injection" ] }, "container": { @@ -729,7 +783,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfDataInjection": { "required": [ @@ -752,7 +809,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfFile": { "required": [ @@ -789,7 +849,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfManifest": { "required": [ @@ -828,7 +891,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfMetadata": { "required": [ @@ -876,7 +942,7 @@ "type": "string", "description": "Comma-separated list of package authors (including contact info)", "examples": [ - "Doug \u0026#60;hello@defenseunicorns.com\u0026#62;\u0026#44; Pepr \u0026#60;hello@defenseunicorns.com\u0026#62;" + "Doug <hello@defenseunicorns.com>, Pepr <hello@defenseunicorns.com>" ] }, "documentation": { @@ -897,7 +963,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfPackage": { "required": [ @@ -950,7 +1019,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfPackageConstant": { "required": [ @@ -981,7 +1053,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } }, "ZarfPackageVariable": { "required": [ @@ -1027,7 +1102,10 @@ } }, "additionalProperties": false, - "type": "object" + "type": "object", + "patternProperties": { + "^x-": {} + } } } }