Skip to content
Merged
1 change: 1 addition & 0 deletions .nextchanges/bundles/7117.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Zero-value overrides of `presets`, `lifecycle.prevent_destroy` and `deployment` settings in includes now replace non-zero base values, and `bundle validate -o json` shows explicit zero presets. ([#7117](https://github.com/databricks/cli/pull/7117))
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

>>> [CLI] bundle validate -o json
{
"presets": {},
"presets": {
"artifacts_dynamic_version": false,
"jobs_max_concurrent_runs": 0,
"name_prefix": ""
},
"job": {
"name": "job",
"max_concurrent_runs": 1
Expand Down
33 changes: 33 additions & 0 deletions acceptance/bundle/validate/lifecycle_override/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
bundle:
name: test-bundle

resources:
jobs:
j:
name: job
tasks:
- task_key: task
notebook_task:
notebook_path: /notebook
lifecycle:
prevent_destroy: true

clusters:
c:
spark_version: "15.4.x-scala2.12"
node_type_id: "i3.xlarge"
num_workers: 2
lifecycle:
prevent_destroy: true

targets:
dev:
resources:
jobs:
j:
lifecycle:
prevent_destroy: false
clusters:
c:
lifecycle:
prevent_destroy: false
2 changes: 2 additions & 0 deletions acceptance/bundle/validate/lifecycle_override/out.test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = false
EnvMatrix.DMS = ["", "true"]
6 changes: 6 additions & 0 deletions acceptance/bundle/validate/lifecycle_override/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

>>> [CLI] bundle validate -t dev -o json
{
"job_prevent_destroy": false,
"cluster_prevent_destroy": false
}
2 changes: 2 additions & 0 deletions acceptance/bundle/validate/lifecycle_override/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The target override prevent_destroy: false wins over the base prevent_destroy: true
trace $CLI bundle validate -t dev -o json | jq '{job_prevent_destroy: .resources.jobs.j.lifecycle.prevent_destroy, cluster_prevent_destroy: .resources.clusters.c.lifecycle.prevent_destroy}'
5 changes: 5 additions & 0 deletions bundle/config/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ type Deployment struct {
// LatestVersionID is the most recent version recorded for the deployment. It is
// zero when the deployment exists but has no version yet.
LatestVersionID int `json:"latest_version_id,omitempty"`

// ForceSendFields records which fields were explicitly set so that zero-value
// overrides can replace non-zero base values (e.g., fail_on_active_runs: false).
// This field is not serialized to JSON.
ForceSendFields []string `json:"-"`
}
5 changes: 5 additions & 0 deletions bundle/config/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ type Presets struct {

// Tags to add to all resources.
Tags map[string]string `json:"tags,omitempty"`

// ForceSendFields records which fields were explicitly set so that zero-value
// overrides can replace non-zero base values (e.g., name_prefix: "" clearing a base prefix).
// This field is not serialized to JSON.
ForceSendFields []string `json:"-"`
}

// IsExplicitlyEnabled tests whether this feature is explicitly enabled.
Expand Down
6 changes: 6 additions & 0 deletions bundle/config/resources/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ type LifecycleConfig interface {
type Lifecycle struct {
// Lifecycle setting to prevent the resource from being destroyed.
PreventDestroy bool `json:"prevent_destroy,omitempty"`

// ForceSendFields records which fields were explicitly set so that zero-value
// overrides can replace non-zero base values (e.g., prevent_destroy: false in a target
// can override prevent_destroy: true in the base).
// This field is not serialized to JSON.
ForceSendFields []string `json:"-"`
}

// HasPreventDestroy returns true if prevent_destroy is set.
Expand Down
Loading