Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions bundle/internal/schema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import (
"reflect"

"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/bundle/config/resources"
"github.com/databricks/cli/bundle/config/variable"
"github.com/databricks/cli/libs/jsonschema"
"github.com/databricks/databricks-sdk-go/service/jobs"
)

func interpolationPattern(s string) string {
Expand Down Expand Up @@ -66,6 +68,24 @@ func addInterpolationPatterns(typ reflect.Type, s jsonschema.Schema) jsonschema.
}
}

func removeDeprecatedJobsFields(typ reflect.Type, s jsonschema.Schema) jsonschema.Schema {
switch typ {
case reflect.TypeOf(resources.Job{}):
delete(s.Properties, "deployment")
delete(s.Properties, "edit_mode")
delete(s.Properties, "format")
Comment thread
shreyas-goenka marked this conversation as resolved.
Outdated

case reflect.TypeOf(jobs.GitSource{}):
delete(s.Properties, "job_source")
delete(s.Properties, "git_snapshot")

default:
// Do nothing
}

return s
}

func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: go run main.go <output-file>")
Expand All @@ -90,6 +110,7 @@ func main() {
s, err := jsonschema.FromType(reflect.TypeOf(config.Root{}), []func(reflect.Type, jsonschema.Schema) jsonschema.Schema{
p.addDescriptions,
p.addEnums,
removeDeprecatedJobsFields,
Comment thread
shreyas-goenka marked this conversation as resolved.
Outdated
addInterpolationPatterns,
})
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resources:
jobs:
foo:
deployment:
kind: BUNDLE
metadata_file_path: /a/b/c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
targets:
foo:
resources:
jobs:
bar:
edit_mode: whatever
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resources:
jobs:
foo:
format: SINGLE_TASK
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resources:
jobs:
foo:
git_source:
git_provider: GITHUB
git_url: www.whatever.com
git_snapshot:
used_commit: abcdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resources:
jobs:
foo:
git_source:
git_provider: GITHUB
git_url: www.whatever.com
job_source:
import_from_git_branch: master
job_config_path: def
5 changes: 3 additions & 2 deletions bundle/internal/schema/testdata/pass/job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ resources:
name: myjob
continuous:
pause_status: PAUSED
edit_mode: EDITABLE
max_concurrent_runs: 10
description: "my job description"
email_notifications:
Expand All @@ -43,10 +42,12 @@ resources:
dependencies:
- python=3.7
client: "myclient"
format: MULTI_TASK
tags:
foo: bar
bar: baz
git_source:
git_provider: gitHub
git_url: www.github.com/a/b
tasks:
- task_key: mytask
notebook_task:
Expand Down
4 changes: 2 additions & 2 deletions bundle/schema/embed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestJsonSchema(t *testing.T) {

// Assert job fields have their descriptions loaded.
resourceJob := walk(s.Definitions, "github.com", "databricks", "cli", "bundle", "config", "resources.Job")
fields := []string{"name", "continuous", "deployment", "tasks", "trigger"}
fields := []string{"name", "continuous", "tasks", "trigger"}
for _, field := range fields {
assert.NotEmpty(t, resourceJob.AnyOf[0].Properties[field].Description)
}
Expand All @@ -53,7 +53,7 @@ func TestJsonSchema(t *testing.T) {

// Assert descriptions are loaded for pipelines
pipeline := walk(s.Definitions, "github.com", "databricks", "cli", "bundle", "config", "resources.Pipeline")
fields = []string{"name", "catalog", "clusters", "channel", "continuous", "deployment", "development"}
fields = []string{"name", "catalog", "clusters", "channel", "continuous", "development"}
for _, field := range fields {
assert.NotEmpty(t, pipeline.AnyOf[0].Properties[field].Description)
}
Expand Down
245 changes: 226 additions & 19 deletions bundle/schema/jsonschema.json

Large diffs are not rendered by default.