Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-goenka committed Sep 10, 2024
1 parent 176bb4b commit 507b99d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 19 deletions.
6 changes: 3 additions & 3 deletions bundle/config/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{
Expand Down
5 changes: 4 additions & 1 deletion bundle/config/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"`

Expand Down
13 changes: 13 additions & 0 deletions bundle/internal/schema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
64 changes: 49 additions & 15 deletions bundle/schema/jsonschema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 507b99d

Please sign in to comment.