Change variables block to map of any in `Targets` struct

This commit is contained in:
Shreyas Goenka 2024-09-04 15:44:53 +02:00
parent e1a8e03cea
commit 48af9d1c57
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
2 changed files with 35 additions and 3 deletions

View File

@ -2,7 +2,6 @@ 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"
)
@ -38,7 +37,26 @@ type Target struct {
// Override default values or lookup name for defined variables
// Does not permit defining new variables or redefining existing ones
// in the scope of an target
Variables map[string]*variable.Variable `json:"variables,omitempty"`
//
// There are two valid ways to define a variable override in a target:
// 1. Direct value override. We normalize this to the variable.Variable
// struct format when loading the configuration YAML:
//
// variables:
// foo: "value"
//
// 2. Override matching the variable.Variable struct.
//
// variables:
// foo:
// default: "value"
//
// OR
//
// variables:
// foo:
// lookup: "resource_name"
Variables map[string]any `json:"variables,omitempty"`
Git Git `json:"git,omitempty"`

View File

@ -995,7 +995,7 @@
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.Sync"
},
"variables": {
"$ref": "#/$defs/map/github.com/databricks/cli/bundle/config/variable.Variable"
"$ref": "#/$defs/map/interface"
},
"workspace": {
"$ref": "#/$defs/github.com/databricks/cli/bundle/config.Workspace"
@ -5054,6 +5054,20 @@
}
}
},
"interface": {
"anyOf": [
{
"type": "object",
"additionalProperties": {
"$ref": "#/$defs/interface"
}
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)*(\\[[0-9]+\\])*)\\}"
}
]
},
"string": {
"anyOf": [
{