Address comments

This commit is contained in:
Shreyas Goenka 2024-09-05 13:37:45 +02:00
parent 9689a79f22
commit c365fd424b
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
2 changed files with 47 additions and 55 deletions

View File

@ -22,14 +22,17 @@ func addInterpolationPatterns(typ reflect.Type, s jsonschema.Schema) jsonschema.
} }
// The variables block in a target override allows for directly specifying // The variables block in a target override allows for directly specifying
// the value if it is a primitive type. // the value of the variable.
if typ == reflect.TypeOf(variable.TargetVariable{}) { if typ == reflect.TypeOf(variable.TargetVariable{}) {
return jsonschema.Schema{ return jsonschema.Schema{
AnyOf: []jsonschema.Schema{s, AnyOf: []jsonschema.Schema{
{Type: jsonschema.StringType}, // We keep the original schema so that autocomplete suggestions
{Type: jsonschema.BooleanType}, // continue to work.
{Type: jsonschema.IntegerType}, s,
{Type: jsonschema.NumberType}, // All values are valid for a variable value, be it primitive types
// like string/bool or complex ones like objects/arrays. Thus we override
// the schema to allow all valid JSON values.
{},
}, },
} }
} }

View File

@ -642,6 +642,29 @@
} }
] ]
}, },
"variable.TargetVariable": {
"anyOf": [
{
"type": "object",
"properties": {
"default": {
"$ref": "#/$defs/interface"
},
"description": {
"$ref": "#/$defs/string"
},
"lookup": {
"$ref": "#/$defs/github.com/databricks/cli/bundle/config/variable.Lookup"
},
"type": {
"$ref": "#/$defs/github.com/databricks/cli/bundle/config/variable.VariableType"
}
},
"additionalProperties": false
},
{}
]
},
"variable.Variable": { "variable.Variable": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -995,7 +1018,7 @@
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.Sync" "$ref": "#/$defs/github.com/databricks/cli/bundle/config.Sync"
}, },
"variables": { "variables": {
"$ref": "#/$defs/map/github.com/databricks/cli/bundle/config.TargetVariable" "$ref": "#/$defs/map/github.com/databricks/cli/bundle/config/variable.TargetVariable"
}, },
"workspace": { "workspace": {
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.Workspace" "$ref": "#/$defs/github.com/databricks/cli/bundle/config.Workspace"
@ -1009,40 +1032,6 @@
} }
] ]
}, },
"config.TargetVariable": {
"anyOf": [
{
"type": "object",
"properties": {
"default": {
"$ref": "#/$defs/interface"
},
"description": {
"$ref": "#/$defs/string"
},
"lookup": {
"$ref": "#/$defs/github.com/databricks/cli/bundle/config/variable.Lookup"
},
"type": {
"$ref": "#/$defs/github.com/databricks/cli/bundle/config/variable.VariableType"
}
},
"additionalProperties": false
},
{
"type": "string"
},
{
"type": "boolean"
},
{
"type": "integer"
},
{
"type": "number"
}
]
},
"config.Workspace": { "config.Workspace": {
"anyOf": [ "anyOf": [
{ {
@ -5027,6 +5016,20 @@
} }
] ]
}, },
"variable.TargetVariable": {
"anyOf": [
{
"type": "object",
"additionalProperties": {
"$ref": "#/$defs/github.com/databricks/cli/bundle/config/variable.TargetVariable"
}
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)*(\\[[0-9]+\\])*)\\}"
}
]
},
"variable.Variable": { "variable.Variable": {
"anyOf": [ "anyOf": [
{ {
@ -5083,20 +5086,6 @@
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}" "pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
} }
] ]
},
"config.TargetVariable": {
"anyOf": [
{
"type": "object",
"additionalProperties": {
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.TargetVariable"
}
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)*(\\[[0-9]+\\])*)\\}"
}
]
} }
} }
} }