Skip to content

Commit

Permalink
Add end to end tests to validate the generated JSON schema
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-goenka committed Jun 26, 2024
1 parent cdd6fe8 commit f471fab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,9 @@ jobs:
run: |
go run main.go bundle schema > schema.json
ajv -s schema.json -d ./bundle/tests/basic/databricks.yml
# Valid configuration should pass schema validation.
for file in ./bundle/tests/jsonschema/allowed/*.yml; do
echo "validating $file"
ajv -s schema.json -d $file
done
2 changes: 1 addition & 1 deletion bundle/config/mutator/resolve_variable_references.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (m *resolveVariableReferences) Apply(ctx context.Context, b *bundle.Bundle)
normalized, _ := convert.Normalize(b.Config, root, convert.IncludeMissingFields)

// If the pattern is nil, we resolve references in the entire configuration.
root, err := dyn.MapByPattern(root, m.pattern, func(p dyn.Path, v dyn.Value) (dyn.Value, error) {
root, err := dyn.MapByPattern(root, m.pattern, func(_ dyn.Path, v dyn.Value) (dyn.Value, error) {
// Resolve variable references in all values.
return dynvar.Resolve(v, func(path dyn.Path) (dyn.Value, error) {
// Rewrite the shorthand path ${var.foo} into ${variables.foo.value}.
Expand Down
18 changes: 18 additions & 0 deletions bundle/tests/jsonschema/allowed/var-reference.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
bundle:
name: variable reference string

variables:
my_var:
description: does not matter
default: "hello"

resources:
jobs:
foo:
name: ${var.my_var}

targets:
staging:
default: true
variables:
my_var: "world"

0 comments on commit f471fab

Please sign in to comment.