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{
|
Targets: map[string]*Target{
|
||||||
"development": {
|
"development": {
|
||||||
Variables: map[string]any{
|
Variables: map[string]*TargetVariable{
|
||||||
"foo": variable.Variable{
|
"foo": {
|
||||||
Default: "bar",
|
Default: "bar",
|
||||||
Description: "wrong",
|
Description: "wrong",
|
||||||
},
|
},
|
||||||
"complex": variable.Variable{
|
"complex": {
|
||||||
Type: "wrong",
|
Type: "wrong",
|
||||||
Description: "wrong",
|
Description: "wrong",
|
||||||
Default: map[string]interface{}{
|
Default: map[string]interface{}{
|
||||||
|
|
|
@ -2,11 +2,14 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/databricks/cli/bundle/config/resources"
|
"github.com/databricks/cli/bundle/config/resources"
|
||||||
|
"github.com/databricks/cli/bundle/config/variable"
|
||||||
"github.com/databricks/databricks-sdk-go/service/jobs"
|
"github.com/databricks/databricks-sdk-go/service/jobs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Mode string
|
type Mode string
|
||||||
|
|
||||||
|
type TargetVariable variable.Variable
|
||||||
|
|
||||||
// Target defines overrides for a single target.
|
// Target defines overrides for a single target.
|
||||||
// This structure is recursively merged into the root configuration.
|
// This structure is recursively merged into the root configuration.
|
||||||
type Target struct {
|
type Target struct {
|
||||||
|
@ -56,7 +59,7 @@ type Target struct {
|
||||||
// variables:
|
// variables:
|
||||||
// foo:
|
// foo:
|
||||||
// lookup: "resource_name"
|
// lookup: "resource_name"
|
||||||
Variables map[string]any `json:"variables,omitempty"`
|
Variables map[string]*TargetVariable `json:"variables,omitempty"`
|
||||||
|
|
||||||
Git Git `json:"git,omitempty"`
|
Git Git `json:"git,omitempty"`
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,19 @@ func addInterpolationPatterns(typ reflect.Type, s jsonschema.Schema) jsonschema.
|
||||||
return s
|
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 {
|
switch s.Type {
|
||||||
case jsonschema.ArrayType, jsonschema.ObjectType:
|
case jsonschema.ArrayType, jsonschema.ObjectType:
|
||||||
// arrays and objects can have complex variable values specified.
|
// arrays and objects can have complex variable values specified.
|
||||||
|
|
|
@ -995,7 +995,7 @@
|
||||||
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.Sync"
|
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.Sync"
|
||||||
},
|
},
|
||||||
"variables": {
|
"variables": {
|
||||||
"$ref": "#/$defs/map/interface"
|
"$ref": "#/$defs/map/github.com/databricks/cli/bundle/config.TargetVariable"
|
||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.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": {
|
"config.Workspace": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
|
@ -5049,17 +5083,13 @@
|
||||||
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
|
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"interface": {
|
"config.TargetVariable": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": {
|
"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]+\\])*)\\}"
|
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)*(\\[[0-9]+\\])*)\\}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
|
|
Loading…
Reference in New Issue