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: 1 addition & 0 deletions .nextchanges/bundles/7048.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* The `compute_id` deprecation warning for a target now shows the full path (`targets.<name>.compute_id`). ([#7048](https://github.com/databricks/cli/pull/7048))
4 changes: 2 additions & 2 deletions acceptance/bundle/validate/compute_id_location/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Warning: compute_id is deprecated, please use cluster_id instead
in databricks.yml:3:15

Warning: compute_id is deprecated, please use cluster_id instead
at compute_id
at targets.dev.compute_id
in databricks.yml:7:17

Name: test-bundle
Expand All @@ -24,7 +24,7 @@ Warning: compute_id is deprecated, please use cluster_id instead
in databricks.yml:3:15

Warning: compute_id is deprecated, please use cluster_id instead
at compute_id
at targets.dev.compute_id
in databricks.yml:7:17

Name: test-bundle
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/validate/compute_id_location/test.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Badness = "Target-level compute_id is reported without the target in the path (at compute_id instead of at targets.dev.compute_id), and is reported even when that target is not selected."
Badness = "A target-level compute_id is reported even when that target is not selected: the deprecation is rewritten for every target before target selection."
11 changes: 7 additions & 4 deletions bundle/config/mutator/compute_id_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mutator

import (
"context"
"slices"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/libs/diag"
Expand All @@ -23,12 +24,12 @@ func (m *computeIdToClusterId) Apply(ctx context.Context, b *bundle.Bundle) diag

// The "compute_id" key is set; rewrite it to "cluster_id".
err := b.Config.Mutate(func(v dyn.Value) (dyn.Value, error) {
v, d := rewriteComputeIdToClusterId(v, dyn.NewPath(dyn.Key("bundle")))
v, d := rewriteComputeIdToClusterId(v, dyn.NewPath(dyn.Key("bundle")), nil)
diags = diags.Extend(d)

// Check if the "compute_id" key is set in any target overrides.
return dyn.MapByPattern(v, dyn.NewPattern(dyn.Key("targets"), dyn.AnyKey()), func(p dyn.Path, v dyn.Value) (dyn.Value, error) {
v, d := rewriteComputeIdToClusterId(v, dyn.Path{})
v, d := rewriteComputeIdToClusterId(v, dyn.Path{}, p)
diags = diags.Extend(d)
return v, nil
})
Expand All @@ -38,7 +39,9 @@ func (m *computeIdToClusterId) Apply(ctx context.Context, b *bundle.Bundle) diag
return diags
}

func rewriteComputeIdToClusterId(v dyn.Value, p dyn.Path) (dyn.Value, diag.Diagnostics) {
// rewriteComputeIdToClusterId rewrites p.compute_id to p.cluster_id in v; prefix is the
// path of v in the configuration, used in the diagnostic.
func rewriteComputeIdToClusterId(v dyn.Value, p, prefix dyn.Path) (dyn.Value, diag.Diagnostics) {
var diags diag.Diagnostics
computeIdPath := p.Append(dyn.Key("compute_id"))
computeId, err := dyn.GetByPath(v, computeIdPath)
Expand All @@ -55,7 +58,7 @@ func rewriteComputeIdToClusterId(v dyn.Value, p dyn.Path) (dyn.Value, diag.Diagn
Severity: diag.Warning,
Summary: "compute_id is deprecated, please use cluster_id instead",
Locations: computeId.Locations(),
Paths: dyn.ToStructPaths(computeIdPath),
Paths: dyn.ToStructPaths(slices.Concat(prefix, computeIdPath)),
})

clusterIdPath := p.Append(dyn.Key("cluster_id"))
Expand Down
Loading