mirror of https://github.com/databricks/cli.git
This commit is contained in:
parent
176bb4b382
commit
507b99dca1
|
@ -139,12 +139,12 @@ func TestRootMergeTargetOverridesWithVariables(t *testing.T) {
|
|||
},
|
||||
Targets: map[string]*Target{
|
||||
"development": {
|
||||
Variables: map[string]any{
|
||||
"foo": variable.Variable{
|
||||
Variables: map[string]*TargetVariable{
|
||||
"foo": {
|
||||
Default: "bar",
|
||||
Description: "wrong",
|
||||
},
|
||||
"complex": variable.Variable{
|
||||
"complex": {
|
||||
Type: "wrong",
|
||||
Description: "wrong",
|
||||
Default: map[string]interface{}{
|
||||
|
|
|
@ -2,11 +2,14 @@ package config
|
|||
|
||||
import (
|
||||
"github.com/databricks/cli/bundle/config/resources"
|
||||
"github.com/databricks/cli/bundle/config/variable"
|
||||
"github.com/databricks/databricks-sdk-go/service/jobs"
|
||||
)
|
||||
|
||||
type Mode string
|
||||
|
||||
type TargetVariable variable.Variable
|
||||
|
||||
// Target defines overrides for a single target.
|
||||
// This structure is recursively merged into the root configuration.
|
||||
type Target struct {
|
||||
|
@ -56,7 +59,7 @@ type Target struct {
|
|||
// variables:
|
||||
// foo:
|
||||
// lookup: "resource_name"
|
||||
Variables map[string]any `json:"variables,omitempty"`
|
||||
Variables map[string]*TargetVariable `json:"variables,omitempty"`
|
||||
|
||||
Git Git `json:"git,omitempty"`
|
||||
|
||||
|
|
|
@ -21,6 +21,19 @@ func addInterpolationPatterns(typ reflect.Type, s jsonschema.Schema) jsonschema.
|
|||
return s
|
||||
}
|
||||
|
||||
// The variables block in a target override allows for directly specifying
|
||||
// the value if it is a primitive type.
|
||||
if typ == reflect.TypeOf(config.TargetVariable{}) {
|
||||
return jsonschema.Schema{
|
||||
AnyOf: []jsonschema.Schema{s,
|
||||
{Type: jsonschema.StringType},
|
||||
{Type: jsonschema.BooleanType},
|
||||
{Type: jsonschema.IntegerType},
|
||||
{Type: jsonschema.NumberType},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
switch s.Type {
|
||||
case jsonschema.ArrayType, jsonschema.ObjectType:
|
||||
// arrays and objects can have complex variable values specified.
|
||||
|
|
|
@ -995,7 +995,7 @@
|
|||
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.Sync"
|
||||
},
|
||||
"variables": {
|
||||
"$ref": "#/$defs/map/interface"
|
||||
"$ref": "#/$defs/map/github.com/databricks/cli/bundle/config.TargetVariable"
|
||||
},
|
||||
"workspace": {
|
||||
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.Workspace"
|
||||
|
@ -1009,6 +1009,40 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"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": {
|
||||
"anyOf": [
|
||||
{
|
||||
|
@ -5049,17 +5083,13 @@
|
|||
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"interface": {
|
||||
"config.TargetVariable": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/$defs/interface"
|
||||
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.TargetVariable"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -5067,6 +5097,10 @@
|
|||
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)*(\\[[0-9]+\\])*)\\}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"string": {
|
||||
"anyOf": [
|
||||
|
|
Loading…
Reference in New Issue