From 48af9d1c570578e9d05ea2b78498a0ccedf43b4c Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Wed, 4 Sep 2024 15:44:53 +0200 Subject: [PATCH] Change variables block to map of any in `Targets` struct --- bundle/config/target.go | 22 ++++++++++++++++++++-- bundle/schema/jsonschema.json | 16 +++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/bundle/config/target.go b/bundle/config/target.go index a2ef4d735..4b20fac15 100644 --- a/bundle/config/target.go +++ b/bundle/config/target.go @@ -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"` diff --git a/bundle/schema/jsonschema.json b/bundle/schema/jsonschema.json index 4fe978b87..6de293648 100644 --- a/bundle/schema/jsonschema.json +++ b/bundle/schema/jsonschema.json @@ -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": [ {