Skip to content

Commit 3229dd7

Browse files
authored
Update bind method to use singular resource name in output messages (#2571)
## Why <!-- Why are these changes needed? Provide the context that the reviewer might be missing. For example, were there any decisions behind the change that are not reflected in the code itself? --> Previously, the output messages in the bind method were using the Terraform resource name (e.g., "databricks_job"). This commit changes the implementation to use the resource's singular name (e.g., "job") instead, which provides more user-friendly and consistent messaging. ## Tests <!-- How have you tested the changes? --> Outputs of existing acceptance tests were updated to reflect the change <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent e749ad5 commit 3229dd7

File tree

23 files changed

+164
-110
lines changed

23 files changed

+164
-110
lines changed

acceptance/bundle/deployment/bind/cluster/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ resources:
1717

1818
>>> [CLI] bundle deployment bind cluster1 [CLUSTER-ID] --auto-approve
1919
Updating deployment state...
20-
Successfully bound databricks_cluster with an id '[CLUSTER-ID]'. Run 'bundle deploy' to deploy changes to your workspace
20+
Successfully bound cluster with an id '[CLUSTER-ID]'. Run 'bundle deploy' to deploy changes to your workspace
2121

2222
>>> [CLI] bundle deployment unbind cluster1
2323
Updating deployment state...

acceptance/bundle/deployment/bind/dashboard/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
>>> [CLI] bundle deployment bind dashboard1 [DASHBOARD_ID] --auto-approve
33
Updating deployment state...
4-
Successfully bound databricks_dashboard with an id '[DASHBOARD_ID]'. Run 'bundle deploy' to deploy changes to your workspace
4+
Successfully bound dashboard with an id '[DASHBOARD_ID]'. Run 'bundle deploy' to deploy changes to your workspace
55

66
>>> [CLI] bundle deploy
77
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/bind-dashboard-test-[UNIQUE_NAME]/default/files...

acceptance/bundle/deployment/bind/dashboard/recreation/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
>>> [CLI] bundle deployment bind dashboard1 [DASHBOARD_ID] --auto-approve
33
Updating deployment state...
4-
Successfully bound databricks_dashboard with an id '[DASHBOARD_ID]'. Run 'bundle deploy' to deploy changes to your workspace
4+
Successfully bound dashboard with an id '[DASHBOARD_ID]'. Run 'bundle deploy' to deploy changes to your workspace
55

66
>>> errcode [CLI] bundle deploy
77
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/bind-dashboard-recreation-test-[UNIQUE_NAME]/default/files...

acceptance/bundle/deployment/bind/experiment/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
=== Substitute variables in the template
44
=== Create a pre-defined experiment
55
=== Bind experiment: Updating deployment state...
6-
Successfully bound databricks_mlflow_experiment with an id '[NUMID]'. Run 'bundle deploy' to deploy changes to your workspace
6+
Successfully bound experiment with an id '[NUMID]'. Run 'bundle deploy' to deploy changes to your workspace
77

88
=== Deploy bundle: Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/bind-ml-experiment-test-[UUID]/default/files...
99
Deploying resources...

acceptance/bundle/deployment/bind/registered-model/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ resources:
1717

1818
>>> [CLI] bundle deployment bind model1 main.test-schema-rmodel-[UUID].test-registered-model-[UUID]
1919
Updating deployment state...
20-
Successfully bound databricks_registered_model with an id 'main.test-schema-rmodel-[UUID].test-registered-model-[UUID]'. Run 'bundle deploy' to deploy changes to your workspace
20+
Successfully bound registered_model with an id 'main.test-schema-rmodel-[UUID].test-registered-model-[UUID]'. Run 'bundle deploy' to deploy changes to your workspace
2121

2222
>>> [CLI] bundle deploy
2323
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/bind-registered-model-test-[UNIQUE_NAME]/default/files...

acceptance/bundle/deployment/bind/schema/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
}
88

99
=== Bind schema: Updating deployment state...
10-
Successfully bound databricks_schema with an id 'main.test-schema-[UUID]'. Run 'bundle deploy' to deploy changes to your workspace
10+
Successfully bound schema with an id 'main.test-schema-[UUID]'. Run 'bundle deploy' to deploy changes to your workspace
1111

1212
=== Deploy bundle: Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/bind-schema-test-[UUID]/default/files...
1313
Deploying resources...

acceptance/bundle/deployment/bind/volume/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
=== Create a pre-defined volume:
99
>>> [CLI] bundle deployment bind volume1 main.test-schema-[UUID].volume-[UUID] --auto-approve
1010
Updating deployment state...
11-
Successfully bound databricks_volume with an id 'main.test-schema-[UUID].volume-[UUID]'. Run 'bundle deploy' to deploy changes to your workspace
11+
Successfully bound volume with an id 'main.test-schema-[UUID].volume-[UUID]'. Run 'bundle deploy' to deploy changes to your workspace
1212

1313
>>> [CLI] bundle deploy
1414
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/bind-dashboard-test-[UNIQUE_NAME]/default/files...

bundle/config/resources.go

Lines changed: 19 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ type ConfigResource interface {
3131
// the input workspace client.
3232
Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error)
3333

34+
// ResourceDescription returns a struct containing strings describing a resource
35+
ResourceDescription() resources.ResourceDescription
36+
3437
// TerraformResourceName returns an equivalent name of the resource. For example "databricks_job"
3538
// for jobs and "databricks_pipeline" for pipelines.
3639
TerraformResourceName() string
@@ -51,13 +54,13 @@ type ConfigResource interface {
5154
// ResourceGroup represents a group of resources of the same type.
5255
// It includes a description of the resource type and a map of resources.
5356
type ResourceGroup struct {
54-
Description ResourceDescription
57+
Description resources.ResourceDescription
5558
Resources map[string]ConfigResource
5659
}
5760

5861
// collectResourceMap collects resources of a specific type into a ResourceGroup.
5962
func collectResourceMap[T ConfigResource](
60-
description ResourceDescription,
63+
description resources.ResourceDescription,
6164
input map[string]T,
6265
) ResourceGroup {
6366
r := make(map[string]ConfigResource)
@@ -163,104 +166,20 @@ func (r *Resources) FindResourceByConfigKey(key string) (ConfigResource, error)
163166
return found[0], nil
164167
}
165168

166-
type ResourceDescription struct {
167-
// Singular and plural name when used to refer to the configuration.
168-
SingularName string
169-
PluralName string
170-
171-
// Singular and plural title when used in summaries / terminal UI.
172-
SingularTitle string
173-
PluralTitle string
174-
175-
TerraformResourceName string
176-
}
177-
178169
// SupportedResources returns a map which keys correspond to the resource key in the bundle configuration.
179-
func SupportedResources() map[string]ResourceDescription {
180-
return map[string]ResourceDescription{
181-
"jobs": {
182-
SingularName: "job",
183-
PluralName: "jobs",
184-
SingularTitle: "Job",
185-
PluralTitle: "Jobs",
186-
TerraformResourceName: "databricks_job",
187-
},
188-
"pipelines": {
189-
SingularName: "pipeline",
190-
PluralName: "pipelines",
191-
SingularTitle: "Pipeline",
192-
PluralTitle: "Pipelines",
193-
TerraformResourceName: "databricks_pipeline",
194-
},
195-
"models": {
196-
SingularName: "model",
197-
PluralName: "models",
198-
SingularTitle: "Model",
199-
PluralTitle: "Models",
200-
TerraformResourceName: "databricks_mlflow_model",
201-
},
202-
"experiments": {
203-
SingularName: "experiment",
204-
PluralName: "experiments",
205-
SingularTitle: "Experiment",
206-
PluralTitle: "Experiments",
207-
TerraformResourceName: "databricks_mlflow_experiment",
208-
},
209-
"model_serving_endpoints": {
210-
SingularName: "model_serving_endpoint",
211-
PluralName: "model_serving_endpoints",
212-
SingularTitle: "Model Serving Endpoint",
213-
PluralTitle: "Model Serving Endpoints",
214-
TerraformResourceName: "databricks_model_serving_endpoint",
215-
},
216-
"registered_models": {
217-
SingularName: "registered_model",
218-
PluralName: "registered_models",
219-
SingularTitle: "Registered Model",
220-
PluralTitle: "Registered Models",
221-
TerraformResourceName: "databricks_registered_model",
222-
},
223-
"quality_monitors": {
224-
SingularName: "quality_monitor",
225-
PluralName: "quality_monitors",
226-
SingularTitle: "Quality Monitor",
227-
PluralTitle: "Quality Monitors",
228-
TerraformResourceName: "databricks_quality_monitor",
229-
},
230-
"schemas": {
231-
SingularName: "schema",
232-
PluralName: "schemas",
233-
SingularTitle: "Schema",
234-
PluralTitle: "Schemas",
235-
TerraformResourceName: "databricks_schema",
236-
},
237-
"clusters": {
238-
SingularName: "cluster",
239-
PluralName: "clusters",
240-
SingularTitle: "Cluster",
241-
PluralTitle: "Clusters",
242-
TerraformResourceName: "databricks_cluster",
243-
},
244-
"dashboards": {
245-
SingularName: "dashboard",
246-
PluralName: "dashboards",
247-
SingularTitle: "Dashboard",
248-
PluralTitle: "Dashboards",
249-
TerraformResourceName: "databricks_dashboard",
250-
},
251-
"volumes": {
252-
SingularName: "volume",
253-
PluralName: "volumes",
254-
SingularTitle: "Volume",
255-
PluralTitle: "Volumes",
256-
TerraformResourceName: "databricks_volume",
257-
},
258-
"apps": {
259-
SingularName: "app",
260-
PluralName: "apps",
261-
SingularTitle: "App",
262-
PluralTitle: "Apps",
263-
TerraformResourceName: "databricks_app",
264-
},
170+
func SupportedResources() map[string]resources.ResourceDescription {
171+
return map[string]resources.ResourceDescription{
172+
"jobs": (&resources.Job{}).ResourceDescription(),
173+
"pipelines": (&resources.Pipeline{}).ResourceDescription(),
174+
"models": (&resources.MlflowModel{}).ResourceDescription(),
175+
"experiments": (&resources.MlflowExperiment{}).ResourceDescription(),
176+
"model_serving_endpoints": (&resources.ModelServingEndpoint{}).ResourceDescription(),
177+
"registered_models": (&resources.RegisteredModel{}).ResourceDescription(),
178+
"quality_monitors": (&resources.QualityMonitor{}).ResourceDescription(),
179+
"schemas": (&resources.Schema{}).ResourceDescription(),
180+
"clusters": (&resources.Cluster{}).ResourceDescription(),
181+
"dashboards": (&resources.Dashboard{}).ResourceDescription(),
182+
"volumes": (&resources.Volume{}).ResourceDescription(),
183+
"apps": (&resources.App{}).ResourceDescription(),
265184
}
266185
}

bundle/config/resources/apps.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ func (a *App) Exists(ctx context.Context, w *databricks.WorkspaceClient, name st
4545
return true, nil
4646
}
4747

48+
func (*App) ResourceDescription() ResourceDescription {
49+
return ResourceDescription{
50+
SingularName: "app",
51+
PluralName: "apps",
52+
SingularTitle: "App",
53+
PluralTitle: "Apps",
54+
TerraformResourceName: "databricks_app",
55+
}
56+
}
57+
4858
func (a *App) TerraformResourceName() string {
4959
return "databricks_app"
5060
}

bundle/config/resources/clusters.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ func (s *Cluster) Exists(ctx context.Context, w *databricks.WorkspaceClient, id
3636
return true, nil
3737
}
3838

39+
func (*Cluster) ResourceDescription() ResourceDescription {
40+
return ResourceDescription{
41+
SingularName: "cluster",
42+
PluralName: "clusters",
43+
SingularTitle: "Cluster",
44+
PluralTitle: "Clusters",
45+
TerraformResourceName: "databricks_cluster",
46+
}
47+
}
48+
3949
func (s *Cluster) TerraformResourceName() string {
4050
return "databricks_cluster"
4151
}

0 commit comments

Comments
 (0)