Skip to content

Commit a39b1ed

Browse files
akolar-dbpietern
andauthored
Add support for pipeline tagging (#3086)
## Changes Add support for pipeline tagging to Databricks Bundles ## Why Tagging allows users to tag their pipelines (which makes them filterable through the UI), and propagates the same set of tags to compute. ## Tests Acceptance test, manual test. Depends on #3087 --------- Co-authored-by: Pieter Noordhuis <[email protected]>
1 parent 4319690 commit a39b1ed

File tree

6 files changed

+40
-13
lines changed

6 files changed

+40
-13
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
### CLI
1212

1313
### Bundles
14+
* Add support for tagging pipelines ([#3086](https://github.com/databricks/cli/pull/3086))
1415

1516
### API Changes

acceptance/bundle/templates/default-python/integration_classic/out.validate.dev.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@
143143
],
144144
"name": "[dev [USERNAME]] project_name_[UNIQUE_NAME]_pipeline",
145145
"permissions": [],
146-
"schema": "project_name_[UNIQUE_NAME]_dev"
146+
"schema": "project_name_[UNIQUE_NAME]_dev",
147+
"tags": {
148+
"dev": "[USERNAME]"
149+
}
147150
}
148151
}
149152
},

acceptance/bundle/templates/default-python/integration_classic/output.txt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ Resources:
7474
+ "id": "[UUID]",
7575
"libraries": [
7676
{
77-
@@ -144,5 +147,6 @@
78-
"name": "[dev [USERNAME]] project_name_[UNIQUE_NAME]_pipeline",
79-
"permissions": [],
80-
- "schema": "project_name_[UNIQUE_NAME]_dev"
81-
+ "schema": "project_name_[UNIQUE_NAME]_dev",
77+
@@ -147,5 +150,6 @@
78+
"tags": {
79+
"dev": "[USERNAME]"
80+
- }
81+
+ },
8282
+ "url": "[DATABRICKS_URL]/pipelines/[UUID]"
8383
}
8484
}
@@ -195,7 +195,7 @@ Validation OK!
195195
+ "pause_status": "UNPAUSED",
196196
"periodic": {
197197
"interval": 1,
198-
@@ -127,22 +114,21 @@
198+
@@ -127,25 +114,21 @@
199199
"channel": "CURRENT",
200200
"configuration": {
201201
- "bundle.sourcePath": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src"
@@ -219,11 +219,14 @@ Validation OK!
219219
- "name": "[dev [USERNAME]] project_name_[UNIQUE_NAME]_pipeline",
220220
+ "name": "project_name_[UNIQUE_NAME]_pipeline",
221221
"permissions": [],
222-
- "schema": "project_name_[UNIQUE_NAME]_dev"
222+
- "schema": "project_name_[UNIQUE_NAME]_dev",
223+
- "tags": {
224+
- "dev": "[USERNAME]"
225+
- }
223226
+ "schema": "project_name_[UNIQUE_NAME]_prod"
224227
}
225228
}
226-
@@ -154,10 +140,10 @@
229+
@@ -157,10 +140,10 @@
227230
},
228231
"workspace": {
229232
- "artifact_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/artifacts",
@@ -367,7 +370,7 @@ Resources:
367370
- "development": true,
368371
"edition": "ADVANCED",
369372
"id": "[UUID]",
370-
@@ -141,11 +127,11 @@
373+
@@ -141,14 +127,11 @@
371374
{
372375
"notebook": {
373376
- "path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src/dlt_pipeline"
@@ -379,10 +382,13 @@ Resources:
379382
+ "name": "project_name_[UNIQUE_NAME]_pipeline",
380383
"permissions": [],
381384
- "schema": "project_name_[UNIQUE_NAME]_dev",
385+
- "tags": {
386+
- "dev": "[USERNAME]"
387+
- },
382388
+ "schema": "project_name_[UNIQUE_NAME]_prod",
383389
"url": "[DATABRICKS_URL]/pipelines/[UUID]"
384390
}
385-
@@ -158,10 +144,10 @@
391+
@@ -161,10 +144,10 @@
386392
},
387393
"workspace": {
388394
- "artifact_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/artifacts",

acceptance/bundle/templates/experimental-jobs-as-code/output.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ Warning: Ignoring Databricks CLI version constraint for development build. Requi
104104
],
105105
"name": "[dev [USERNAME]] my_jobs_as_code_pipeline",
106106
"permissions": [],
107+
"tags": {
108+
"dev": "[USERNAME]"
109+
},
107110
"target": "my_jobs_as_code_dev"
108111
}
109112
}

acceptance/pipelines/e2e/output.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ View your pipeline my_project_pipeline_2 here: [DATABRICKS_URL]/pipelines/[UUID]
5454
"edition":"ADVANCED",
5555
"id":"[UUID]",
5656
"name":"[dev [USERNAME]] my_project_pipeline_2",
57-
"storage":"dbfs:/pipelines/[UUID]"
57+
"storage":"dbfs:/pipelines/[UUID]",
58+
"tags": {
59+
"dev":"[USERNAME]"
60+
}
5861
},
5962
"state":"IDLE"
6063
}

bundle/config/mutator/resourcemutator/apply_presets.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,18 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
105105
if t.TriggerPauseStatus == config.Paused {
106106
p.Continuous = false
107107
}
108-
// As of 2024-06, pipelines don't yet support tags
108+
109+
if len(tags) > 0 {
110+
if p.Tags == nil {
111+
// Note: only create this map if tags is not empty, to avoid inserting "tags: {}" entry in the config
112+
p.Tags = make(map[string]string, len(tags))
113+
}
114+
for _, tag := range tags {
115+
if p.Tags[tag.Key] == "" {
116+
p.Tags[tag.Key] = tag.Value
117+
}
118+
}
119+
}
109120
}
110121

111122
// Models presets: Prefix, Tags

0 commit comments

Comments
 (0)