Skip to content

Commit

Permalink
generate original schema still too
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 committed Aug 15, 2024
1 parent a406856 commit 1740a33
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
11 changes: 9 additions & 2 deletions hack/check-zarf-docs-and-schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

set -euo pipefail

if [ -z "$(git status -s ./site/src/content/docs/commands/ ./zarf.schema.json)" ]; then
PATHS=(
"./zarf.schema.json"
"./schema/zarf_package_v1alpha1.schema.json"
"./schema/zarf_package_v1beta1.schema.json"
"./site/src/content/docs/commands/"
)

if [ -z "$(git status -s "${PATHS[@]}")" ]; then
echo "Success!"
exit 0
else
git diff ./site/src/content/docs/commands/ ./zarf.schema.json
git diff "${PATHS[@]}"
exit 1
fi
15 changes: 9 additions & 6 deletions hack/create-zarf-schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -euo pipefail

add_yaml_extensions() {
local input_file=$1
local dst_folder="schema"
local src=$1
local dst=$2

jq '
def addPatternProperties:
Expand All @@ -16,12 +16,15 @@ add_yaml_extensions() {
end;
walk(if type == "object" then addPatternProperties else . end)
' "$input_file" > "$dst_folder/$input_file"
rm "$input_file"
' "$src" > "$dst"
}

go run schema/src/main.go v1alpha1 > "zarf_package_v1alpha1.schema.json"
go run schema/src/main.go v1beta1 > "zarf_package_v1beta1.schema.json"

add_yaml_extensions "zarf_package_v1alpha1.schema.json"
add_yaml_extensions "zarf_package_v1beta1.schema.json"
add_yaml_extensions "zarf_package_v1alpha1.schema.json" "zarf.schema.json"
add_yaml_extensions "zarf_package_v1alpha1.schema.json" "schema/zarf_package_v1alpha1.schema.json"
add_yaml_extensions "zarf_package_v1beta1.schema.json" "schema/zarf_package_v1beta1.schema.json"

rm zarf_package_v1alpha1.schema.json
rm zarf_package_v1beta1.schema.json

0 comments on commit 1740a33

Please sign in to comment.