Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions bundle/apps/interpolate_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAppInterpolateVariables(t *testing.T) {
Resources: config.Resources{
Apps: map[string]*resources.App{
"my_app_1": {
App: &apps.App{
App: apps.App{
Name: "my_app_1",
},
Config: map[string]any{
Expand All @@ -28,7 +28,7 @@ func TestAppInterpolateVariables(t *testing.T) {
},
},
"my_app_2": {
App: &apps.App{
App: apps.App{
Name: "my_app_2",
},
},
Expand Down
2 changes: 1 addition & 1 deletion bundle/apps/upload_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestAppUploadConfig(t *testing.T) {
Resources: config.Resources{
Apps: map[string]*resources.App{
"my_app": {
App: &apps.App{
App: apps.App{
Name: "my_app",
},
SourceCodePath: "./my_app",
Expand Down
4 changes: 2 additions & 2 deletions bundle/apps/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ func TestAppsValidateSameSourcePath(t *testing.T) {
Resources: config.Resources{
Apps: map[string]*resources.App{
"app1": {
App: &apps.App{
App: apps.App{
Name: "app1",
},
SourceCodePath: "./app1",
},
"app2": {
App: &apps.App{
App: apps.App{
Name: "app2",
},
SourceCodePath: "./app1",
Expand Down
22 changes: 11 additions & 11 deletions bundle/config/mutator/initialize_urls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,69 +26,69 @@ func TestInitializeURLs(t *testing.T) {
Jobs: map[string]*resources.Job{
"job1": {
ID: "1",
JobSettings: &jobs.JobSettings{Name: "job1"},
JobSettings: jobs.JobSettings{Name: "job1"},
},
},
Pipelines: map[string]*resources.Pipeline{
"pipeline1": {
ID: "3",
CreatePipeline: &pipelines.CreatePipeline{Name: "pipeline1"},
CreatePipeline: pipelines.CreatePipeline{Name: "pipeline1"},
},
},
Experiments: map[string]*resources.MlflowExperiment{
"experiment1": {
ID: "4",
Experiment: &ml.Experiment{Name: "experiment1"},
Experiment: ml.Experiment{Name: "experiment1"},
},
},
Models: map[string]*resources.MlflowModel{
"model1": {
ID: "a model uses its name for identifier",
Model: &ml.Model{Name: "a model uses its name for identifier"},
Model: ml.Model{Name: "a model uses its name for identifier"},
},
},
ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{
"servingendpoint1": {
ID: "my_serving_endpoint",
CreateServingEndpoint: &serving.CreateServingEndpoint{
CreateServingEndpoint: serving.CreateServingEndpoint{
Name: "my_serving_endpoint",
},
},
},
RegisteredModels: map[string]*resources.RegisteredModel{
"registeredmodel1": {
ID: "8",
CreateRegisteredModelRequest: &catalog.CreateRegisteredModelRequest{
CreateRegisteredModelRequest: catalog.CreateRegisteredModelRequest{
Name: "my_registered_model",
},
},
},
QualityMonitors: map[string]*resources.QualityMonitor{
"qualityMonitor1": {
TableName: "catalog.schema.qualityMonitor1",
CreateMonitor: &catalog.CreateMonitor{},
CreateMonitor: catalog.CreateMonitor{},
},
},
Schemas: map[string]*resources.Schema{
"schema1": {
ID: "catalog.schema",
CreateSchema: &catalog.CreateSchema{
CreateSchema: catalog.CreateSchema{
Name: "schema",
},
},
},
Clusters: map[string]*resources.Cluster{
"cluster1": {
ID: "1017-103929-vlr7jzcf",
ClusterSpec: &compute.ClusterSpec{
ClusterSpec: compute.ClusterSpec{
ClusterName: "cluster1",
},
},
},
Dashboards: map[string]*resources.Dashboard{
"dashboard1": {
ID: "01ef8d56871e1d50ae30ce7375e42478",
Dashboard: &dashboards.Dashboard{
Dashboard: dashboards.Dashboard{
DisplayName: "My special dashboard",
},
},
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestInitializeURLsWithoutOrgId(t *testing.T) {
Jobs: map[string]*resources.Job{
"job1": {
ID: "1",
JobSettings: &jobs.JobSettings{Name: "job1"},
JobSettings: jobs.JobSettings{Name: "job1"},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion bundle/config/mutator/normalize_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func collectGitSourcePaths(b *bundle.Bundle) []dyn.Path {
var jobs []dyn.Path

for name, job := range b.Config.Resources.Jobs {
if job == nil || job.JobSettings == nil {
if job == nil {
continue
}
if job.GitSource != nil {
Expand Down
2 changes: 1 addition & 1 deletion bundle/config/mutator/normalize_paths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestNormalizePaths(t *testing.T) {
Config: config.Root{
Resources: config.Resources{
Jobs: map[string]*resources.Job{
"job1": {JobSettings: &jobs.JobSettings{
"job1": {JobSettings: jobs.JobSettings{
Tasks: []jobs.Task{
{
NotebookTask: &jobs.NotebookTask{
Expand Down
6 changes: 3 additions & 3 deletions bundle/config/mutator/paths/job_paths_visitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestVisitJobPaths(t *testing.T) {
}

job0 := &resources.Job{
JobSettings: &jobs.JobSettings{
JobSettings: jobs.JobSettings{
Tasks: []jobs.Task{
task0,
task1,
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestVisitJobPaths_environments(t *testing.T) {
},
}
job0 := &resources.Job{
JobSettings: &jobs.JobSettings{
JobSettings: jobs.JobSettings{
Environments: []jobs.JobEnvironment{
environment0,
},
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestVisitJobPaths_foreach(t *testing.T) {
},
}
job0 := &resources.Job{
JobSettings: &jobs.JobSettings{
JobSettings: jobs.JobSettings{
Tasks: []jobs.Task{
task0,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestVisitPipelinePaths(t *testing.T) {
Resources: config.Resources{
Pipelines: map[string]*resources.Pipeline{
"pipeline0": {
CreatePipeline: &pipelines.CreatePipeline{
CreatePipeline: pipelines.CreatePipeline{
Libraries: []pipelines.PipelineLibrary{
{
File: &pipelines.FileLibrary{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestResolveVariableReferencesWithSourceLinkedDeployment(t *testing.T) {
Resources: config.Resources{
Pipelines: map[string]*resources.Pipeline{
"pipeline1": {
CreatePipeline: &pipelines.CreatePipeline{
CreatePipeline: pipelines.CreatePipeline{
Configuration: map[string]string{
"source": "${workspace.file_path}",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func TestApplyBundlePermissions(t *testing.T) {
Resources: config.Resources{
Jobs: map[string]*resources.Job{
"job_1": {
JobSettings: &jobs.JobSettings{
JobSettings: jobs.JobSettings{
Name: "job_1",
},
},
"job_2": {
JobSettings: &jobs.JobSettings{
JobSettings: jobs.JobSettings{
Name: "job_2",
},
},
Expand Down Expand Up @@ -139,15 +139,15 @@ func TestWarningOnOverlapPermission(t *testing.T) {
Resources: config.Resources{
Jobs: map[string]*resources.Job{
"job_1": {
JobSettings: &jobs.JobSettings{
JobSettings: jobs.JobSettings{
Name: "job_1",
},
Permissions: []resources.JobPermission{
{Level: "CAN_VIEW", UserName: "TestUser"},
},
},
"job_2": {
JobSettings: &jobs.JobSettings{
JobSettings: jobs.JobSettings{
Name: "job_2",
},
Permissions: []resources.JobPermission{
Expand Down
37 changes: 1 addition & 36 deletions bundle/config/mutator/resourcemutator/apply_presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ import (
"github.com/databricks/cli/libs/dyn"
"github.com/databricks/cli/libs/textutil"
"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/databricks/databricks-sdk-go/service/compute"
"github.com/databricks/databricks-sdk-go/service/dashboards"
"github.com/databricks/databricks-sdk-go/service/jobs"
"github.com/databricks/databricks-sdk-go/service/ml"
"github.com/databricks/databricks-sdk-go/service/pipelines"
"github.com/databricks/databricks-sdk-go/service/serving"
)

type applyPresets struct{}
Expand Down Expand Up @@ -59,9 +55,6 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
if j == nil {
continue
}
if j.JobSettings == nil {
j.JobSettings = &jobs.JobSettings{}
}
j.Name = prefix + j.Name
if len(tags) > 0 {
if j.Tags == nil {
Expand Down Expand Up @@ -100,9 +93,6 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
if p == nil {
continue
}
if p.CreatePipeline == nil {
p.CreatePipeline = &pipelines.CreatePipeline{}
}
p.Name = prefix + p.Name
if config.IsExplicitlyEnabled(t.PipelinesDevelopment) {
p.Development = true
Expand All @@ -118,9 +108,6 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
if m == nil {
continue
}
if m.Model == nil {
m.Model = &ml.Model{}
}
m.Name = prefix + m.Name
for _, t := range tags {
exists := slices.ContainsFunc(m.Tags, func(modelTag ml.ModelTag) bool {
Expand All @@ -138,9 +125,6 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
if e == nil {
continue
}
if e.Experiment == nil {
e.Experiment = &ml.Experiment{}
}
filepath := e.Name
dir := path.Dir(filepath)
base := path.Base(filepath)
Expand Down Expand Up @@ -168,9 +152,6 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
if e == nil {
continue
}
if e.CreateServingEndpoint == nil {
e.CreateServingEndpoint = &serving.CreateServingEndpoint{}
}
e.Name = normalizePrefix(prefix) + e.Name

// As of 2024-06, model serving endpoints don't yet support tags
Expand All @@ -181,21 +162,14 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
if m == nil {
continue
}
if m.CreateRegisteredModelRequest == nil {
m.CreateRegisteredModelRequest = &catalog.CreateRegisteredModelRequest{}
}
m.Name = normalizePrefix(prefix) + m.Name

// As of 2024-06, registered models don't yet support tags
}

// Quality monitors presets: Schedule
if t.TriggerPauseStatus == config.Paused {
for key, q := range r.QualityMonitors {
if q.CreateMonitor == nil {
diags = diags.Extend(diag.Errorf("quality monitor %s is not defined", key))
continue
}
for _, q := range r.QualityMonitors {
// Remove all schedules from monitors, since they don't support pausing/unpausing.
// Quality monitors might support the "pause" property in the future, so at the
// CLI level we do respect that property if it is set to "unpaused."
Expand All @@ -210,9 +184,6 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
if s == nil {
continue
}
if s.CreateSchema == nil {
s.CreateSchema = &catalog.CreateSchema{}
}
s.Name = normalizePrefix(prefix) + s.Name
// HTTP API for schemas doesn't yet support tags. It's only supported in
// the Databricks UI and via the SQL API.
Expand All @@ -223,9 +194,6 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
if c == nil {
continue
}
if c.ClusterSpec == nil {
c.ClusterSpec = &compute.ClusterSpec{}
}
c.ClusterName = prefix + c.ClusterName
if c.CustomTags == nil {
c.CustomTags = make(map[string]string)
Expand All @@ -244,9 +212,6 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
if dashboard == nil {
continue
}
if dashboard.Dashboard == nil {
dashboard.Dashboard = &dashboards.Dashboard{}
}
dashboard.DisplayName = prefix + dashboard.DisplayName
}

Expand Down
Loading
Loading