mirror of https://github.com/databricks/cli.git
Allow yaml-anchors in schema (#2200)
## Changes Allows custom untyped fields in the root config in json-schema so it doesn't highlight errors when using yaml-anchors. Example use case: ``` tags: &job-tags environment: ${bundle.target} resources: jobs: db1: tags: <<: *job-tags db1: tags: <<: *job-tags ``` One downside is that we don't highlight any unknown top-level properties anymore (but they will still fail during CLI validation) ## Tests Manually checked behavior in VSCode - it doesn't show validation error. Also checked that other typed properties are still suggested
This commit is contained in:
parent
ba3a400327
commit
f60ad32f07
|
@ -172,6 +172,15 @@ func generateSchema(workdir, outputFile string) {
|
|||
a.addAnnotations,
|
||||
addInterpolationPatterns,
|
||||
})
|
||||
|
||||
// AdditionalProperties is set to an empty schema to allow non-typed keys used as yaml-anchors
|
||||
// Example:
|
||||
// some_anchor: &some_anchor
|
||||
// file_path: /some/path/
|
||||
// workspace:
|
||||
// <<: *some_anchor
|
||||
s.AdditionalProperties = jsonschema.Schema{}
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
unknown: value
|
|
@ -0,0 +1,11 @@
|
|||
tags: &job-tags
|
||||
environment: "some_environment"
|
||||
|
||||
resources:
|
||||
jobs:
|
||||
db1:
|
||||
tags:
|
||||
<<: *job-tags
|
||||
db2:
|
||||
tags:
|
||||
<<: *job-tags
|
|
@ -7269,5 +7269,5 @@
|
|||
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.Workspace"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
"additionalProperties": {}
|
||||
}
|
Loading…
Reference in New Issue