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
1 change: 0 additions & 1 deletion NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## Release v0.269.0

### Notable Changes
* Add support for SQL Alerts in DABs ([#3033](https://github.com/databricks/cli/pull/3033))

### CLI

Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/deploy/alerts/basic/out.test.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Local = false
Cloud = true
Cloud = false

[EnvMatrix]
DATABRICKS_CLI_DEPLOYMENT = ["terraform"]
2 changes: 1 addition & 1 deletion acceptance/bundle/deploy/alerts/basic/test.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Cloud = true
Cloud = false
Local = false

# Permissions with alerts does not work with direct deployment yet.
Expand Down
1 change: 1 addition & 0 deletions acceptance/bundle/deployment/bind/alert/test.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Cloud = false
Local = false # Enable when releasing support for alerts.
Comment thread
shreyas-goenka marked this conversation as resolved.
Resolved

BundleConfigTarget = "databricks.yml"
45 changes: 12 additions & 33 deletions acceptance/bundle/summary/modified_status/output.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@

=== Initial view of resources without id and modified_status=created
>>> [CLI] bundle summary -o json
Warning: unknown field: alerts
at resources
in databricks.yml:4:3

{
"alerts": {
"my_alert": {
"custom_description": "test-alert-description",
"custom_summary": "test-alert-summary",
"display_name": "test-alert",
"modified_status": "created",
"parent_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/resources",
"permissions": [],
"query_text": "SELECT 1",
"warehouse_id": "test-sql-warehouse"
}
},
"pipelines": {
"my_pipeline": {
"channel": "CURRENT",
Expand Down Expand Up @@ -58,27 +50,22 @@
}

>>> [CLI] bundle deploy
Warning: unknown field: alerts
at resources
in databricks.yml:4:3

Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

=== Post-deployment view of resources with id and without modified_status
>>> [CLI] bundle summary -o json
Warning: unknown field: alerts
at resources
in databricks.yml:4:3

{
"alerts": {
"my_alert": {
"custom_description": "test-alert-description",
"custom_summary": "test-alert-summary",
"display_name": "test-alert",
"id": "[UUID]",
"parent_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/resources",
"permissions": [],
"query_text": "SELECT 1",
"url": "[DATABRICKS_URL]/sql/alerts-v2/[UUID]?o=[NUMID]",
"warehouse_id": "test-sql-warehouse"
}
},
"pipelines": {
"my_pipeline": {
"channel": "CURRENT",
Expand Down Expand Up @@ -128,13 +115,6 @@ Deployment complete!
=== Expecting all resources to have modified_status=deleted
>>> [CLI] bundle summary -o json
{
"alerts": {
"my_alert": {
"id": "[UUID]",
"modified_status": "deleted",
"url": "[DATABRICKS_URL]/sql/alerts-v2/[UUID]?o=[NUMID]"
}
},
"pipelines": {
"my_pipeline": {
"id": "[UUID]",
Expand All @@ -160,7 +140,6 @@ Deployment complete!

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete alert my_alert
delete pipeline my_pipeline
delete schema my_schema
delete sql_warehouse my_sql_warehouse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,8 @@ Error: secret_scope rname is not defined
}

=== resources.alerts.rname ===
Error: alert rname is not defined
at resources.alerts.rname
in databricks.yml:6:11
Warning: unknown field: alerts
at resources
in databricks.yml:5:3

{
"alerts": {
"rname": null
}
}
{}
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,8 @@ Warning: required field "name" is not set
}

=== resources.alerts.rname ===
{
"alerts": {
"rname": {
"parent_path": "/Workspace/Users/[USERNAME]/.bundle/BUNDLE/default/resources",
"permissions": []
}
}
}
Warning: unknown field: alerts
at resources
in databricks.yml:5:3

{}
12 changes: 4 additions & 8 deletions acceptance/bundle/validate/empty_resources/null/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,8 @@ Error: secret_scope rname is not defined
}

=== resources.alerts.rname ===
Error: alert rname is not defined
at resources.alerts.rname
in databricks.yml:6:12
Warning: unknown field: alerts
at resources
in databricks.yml:5:3

{
"alerts": {
"rname": null
}
}
{}
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,8 @@ Warning: required field "name" is not set
}

=== resources.alerts.rname ===
Warning: unknown field: grants
at resources.alerts.rname
in databricks.yml:7:7
Warning: unknown field: alerts
at resources
in databricks.yml:5:3

{
"alerts": {
"rname": {
"parent_path": "/Workspace/Users/[USERNAME]/.bundle/BUNDLE/default/resources",
"permissions": []
}
}
}
{}
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,8 @@ Warning: required field "name" is not set
}

=== resources.alerts.rname ===
{
"alerts": {
"rname": {
"parent_path": "/Workspace/Users/[USERNAME]/.bundle/BUNDLE/default/resources",
"permissions": []
}
}
}
Warning: unknown field: alerts
at resources
in databricks.yml:5:3

{}
33 changes: 12 additions & 21 deletions acceptance/bundle/validate/presets_name_prefix/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
name_prefix: "prefix-"

>>> [CLI] bundle validate -o json
Warning: unknown field: alerts
at resources
in databricks.yml:22:3

Warning: required field "catalog_name" is not set
at resources.schemas.schema1
in databricks.yml:14:7

{
"alerts": {
"alert1": {
"display_name": "prefix-alert1",
"parent_path": "/Workspace/foo/bar",
"permissions": []
}
},
"jobs": {
"job1": {
"deployment": {
Expand Down Expand Up @@ -50,18 +47,15 @@ Warning: required field "catalog_name" is not set
name_prefix: "[prefix]"

>>> [CLI] bundle validate -o json
Warning: unknown field: alerts
at resources
in databricks.yml:22:3

Warning: required field "catalog_name" is not set
at resources.schemas.schema1
in databricks.yml:14:7

{
"alerts": {
"alert1": {
"display_name": "[prefix]alert1",
"parent_path": "/Workspace/foo/bar",
"permissions": []
}
},
"jobs": {
"job1": {
"deployment": {
Expand Down Expand Up @@ -97,18 +91,15 @@ Warning: required field "catalog_name" is not set
name_prefix: ""

>>> [CLI] bundle validate -o json
Warning: unknown field: alerts
at resources
in databricks.yml:22:3

Warning: required field "catalog_name" is not set
at resources.schemas.schema1
in databricks.yml:14:7

{
"alerts": {
"alert1": {
"display_name": "alert1",
"parent_path": "/Workspace/foo/bar",
"permissions": []
}
},
"jobs": {
"job1": {
"deployment": {
Expand Down
12 changes: 6 additions & 6 deletions bundle/config/mutator/resourcemutator/apply_presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
// Apps: No presets

// Alerts: Prefix
for _, a := range r.Alerts {
if a == nil {
continue
}
a.DisplayName = prefix + a.DisplayName
}
// for _, a := range r.Alerts {
// if a == nil {
// continue
// }
// a.DisplayName = prefix + a.DisplayName
// }

// SQL Warehouses: Prefix, Tags
for _, w := range r.SqlWarehouses {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ func mockBundle(mode config.Mode) *bundle.Bundle {
},
},
},
Alerts: map[string]*resources.Alert{
"alert1": {
AlertV2: sql.AlertV2{
DisplayName: "alert1",
},
},
},
// Alerts: map[string]*resources.Alert{
// "alert1": {
// AlertV2: sql.AlertV2{
// DisplayName: "alert1",
// },
// },
// },
},
},
SyncRoot: vfs.MustNew("/Users/lennart.kats@databricks.com"),
Expand Down
18 changes: 9 additions & 9 deletions bundle/config/mutator/resourcemutator/run_as.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ func validateRunAs(b *bundle.Bundle) diag.Diagnostics {
))
}

// Alerts do not support run_as in the API.
if len(b.Config.Resources.Alerts) > 0 {
diags = diags.Extend(reportRunAsNotSupported(
"alerts",
b.Config.GetLocation("resources.alerts"),
b.Config.Workspace.CurrentUser.UserName,
identity,
))
}
// // Alerts do not support run_as in the API.
// if len(b.Config.Resources.Alerts) > 0 {
// diags = diags.Extend(reportRunAsNotSupported(
// "alerts",
// b.Config.GetLocation("resources.alerts"),
// b.Config.Workspace.CurrentUser.UserName,
// identity,
// ))
// }

// Apps do not support run_as in the API.
if len(b.Config.Resources.Apps) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion bundle/config/mutator/resourcemutator/run_as_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func allResourceTypes(t *testing.T) []string {
// the dyn library gives us the correct list of all resources supported. Please
// also update this check when adding a new resource
require.Equal(t, []string{
"alerts",
// "alerts",
"apps",
"clusters",
"dashboards",
Expand Down
32 changes: 16 additions & 16 deletions bundle/config/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ type Resources struct {
Dashboards map[string]*resources.Dashboard `json:"dashboards,omitempty"`
Apps map[string]*resources.App `json:"apps,omitempty"`
SecretScopes map[string]*resources.SecretScope `json:"secret_scopes,omitempty"`
Alerts map[string]*resources.Alert `json:"alerts,omitempty"`
SqlWarehouses map[string]*resources.SqlWarehouse `json:"sql_warehouses,omitempty"`
DatabaseInstances map[string]*resources.DatabaseInstance `json:"database_instances,omitempty"`
DatabaseCatalogs map[string]*resources.DatabaseCatalog `json:"database_catalogs,omitempty"`
SyncedDatabaseTables map[string]*resources.SyncedDatabaseTable `json:"synced_database_tables,omitempty"`
// Alerts map[string]*resources.Alert `json:"alerts,omitempty"`
SqlWarehouses map[string]*resources.SqlWarehouse `json:"sql_warehouses,omitempty"`
DatabaseInstances map[string]*resources.DatabaseInstance `json:"database_instances,omitempty"`
DatabaseCatalogs map[string]*resources.DatabaseCatalog `json:"database_catalogs,omitempty"`
SyncedDatabaseTables map[string]*resources.SyncedDatabaseTable `json:"synced_database_tables,omitempty"`
}

type ConfigResource interface {
Expand Down Expand Up @@ -92,7 +92,7 @@ func (r *Resources) AllResources() []ResourceGroup {
collectResourceMap(descriptions["dashboards"], r.Dashboards),
collectResourceMap(descriptions["volumes"], r.Volumes),
collectResourceMap(descriptions["apps"], r.Apps),
collectResourceMap(descriptions["alerts"], r.Alerts),
// collectResourceMap(descriptions["alerts"], r.Alerts),
collectResourceMap(descriptions["secret_scopes"], r.SecretScopes),
collectResourceMap(descriptions["sql_warehouses"], r.SqlWarehouses),
collectResourceMap(descriptions["database_instances"], r.DatabaseInstances),
Expand Down Expand Up @@ -175,11 +175,11 @@ func (r *Resources) FindResourceByConfigKey(key string) (ConfigResource, error)
}
}

for k := range r.Alerts {
if k == key {
found = append(found, r.Alerts[k])
}
}
// for k := range r.Alerts {
// if k == key {
// found = append(found, r.Alerts[k])
// }
// }

for k := range r.SqlWarehouses {
if k == key {
Expand Down Expand Up @@ -236,10 +236,10 @@ func SupportedResources() map[string]resources.ResourceDescription {
"volumes": (&resources.Volume{}).ResourceDescription(),
"apps": (&resources.App{}).ResourceDescription(),
"secret_scopes": (&resources.SecretScope{}).ResourceDescription(),
"alerts": (&resources.Alert{}).ResourceDescription(),
"sql_warehouses": (&resources.SqlWarehouse{}).ResourceDescription(),
"database_instances": (&resources.DatabaseInstance{}).ResourceDescription(),
"database_catalogs": (&resources.DatabaseCatalog{}).ResourceDescription(),
"synced_database_tables": (&resources.SyncedDatabaseTable{}).ResourceDescription(),
// "alerts": (&resources.Alert{}).ResourceDescription(),
"sql_warehouses": (&resources.SqlWarehouse{}).ResourceDescription(),
"database_instances": (&resources.DatabaseInstance{}).ResourceDescription(),
"database_catalogs": (&resources.DatabaseCatalog{}).ResourceDescription(),
"synced_database_tables": (&resources.SyncedDatabaseTable{}).ResourceDescription(),
}
}
Loading