Skip to content

Commit e46c3fb

Browse files
authored
Make config-remote-sync patching logic more generic (#4400)
## Changes Split the config-remote-sync command into 3 separate phases. Previously, some DAB-specific logic was embedded in the patcher, now it 1. Detect (diff.go) - Compare states, handle server-side and CLI defaults. Convert value to the internal struct. Compute which operation type should be applied to the config 2. Resolve (resolve.go) - Determine file locations and field paths. Replace [task_key=foo] selectors 3. Patch (patch.go) - Now only handles YAML modifications, doesn't hold any config-specific logic Changes: 1. new ConfigChangeDesc struct 2. normalizeValue() moved from patch.go to diff.go 3. selector handling moved to `resolve.go` 4. /targets/ prefixes moved from `patch.go` to `resolve.go` 5. new explicit type for operations which we also show in the output 6. removed bunch of redundant tests - this logic is covered in acceptance suites ## Why Preparation before the next PR, where I plan to properly handle CLI defaults ## Tests 1. Updated snapshots to capture new debug output 2. Removed redundant unit tests - these cases are already covered with acceptance tests <!-- 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 ef02c2f commit e46c3fb

File tree

21 files changed

+353
-1112
lines changed

21 files changed

+353
-1112
lines changed

acceptance/bundle/config-remote-sync/config_edits/output.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ Deployment complete!
2222
Detected changes in 1 resource(s):
2323

2424
Resource: resources.jobs.my_job
25-
email_notifications.on_failure[0]: update
26-
max_concurrent_runs: update
27-
tags['env']: update
25+
email_notifications.on_failure[0]: replace
26+
max_concurrent_runs: replace
27+
tags['env']: remove
28+
2829

2930

3031
=== Configuration changes

acceptance/bundle/config-remote-sync/formatting_preserved/output.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Deployment complete!
88
Detected changes in 1 resource(s):
99

1010
Resource: resources.jobs.my_job
11-
max_concurrent_runs: update
11+
max_concurrent_runs: replace
12+
1213

1314

1415
=== Configuration changes

acceptance/bundle/config-remote-sync/job_fields/output.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ Deployment complete!
1010
Detected changes in 1 resource(s):
1111

1212
Resource: resources.jobs.my_job
13-
email_notifications.no_alert_for_skipped_runs: skip
14-
email_notifications.on_failure: skip
15-
parameters: update
16-
tags['team']: update
17-
trigger.periodic.interval: update
13+
email_notifications.no_alert_for_skipped_runs: add
14+
email_notifications.on_failure: add
15+
parameters: replace
16+
tags['team']: add
17+
trigger.periodic.interval: replace
18+
1819

1920

2021
=== Configuration changes

acceptance/bundle/config-remote-sync/job_multiple_tasks/output.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ Deployment complete!
88
Detected changes in 1 resource(s):
99

1010
Resource: resources.jobs.my_job
11-
tasks[task_key='task2']: update
12-
tasks[task_key='task3'].depends_on[0].task_key: update
13-
tasks[task_key='task3'].new_cluster.num_workers: update
14-
tasks[task_key='task3'].timeout_seconds: skip
11+
tasks[task_key='task2']: remove
12+
tasks[task_key='task3'].depends_on[0].task_key: replace
13+
tasks[task_key='task3'].new_cluster.num_workers: replace
14+
tasks[task_key='task3'].timeout_seconds: add
15+
1516

1617

1718
=== Configuration changes

acceptance/bundle/config-remote-sync/job_pipeline_task/output.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ Deployment complete!
99
Detected changes in 2 resource(s):
1010

1111
Resource: resources.jobs.my_job
12-
tasks[task_key='run_pipeline'].pipeline_task.full_refresh: update
12+
tasks[task_key='run_pipeline'].pipeline_task.full_refresh: replace
13+
1314
Resource: resources.pipelines.my_pipeline
14-
development: update
15+
development: replace
16+
1517

1618

1719
=== Configuration changes

acceptance/bundle/config-remote-sync/multiple_files/output.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ Deployment complete!
88
Detected changes in 2 resource(s):
99

1010
Resource: resources.jobs.job_one
11-
max_concurrent_runs: update
11+
max_concurrent_runs: replace
12+
1213
Resource: resources.jobs.job_two
13-
max_concurrent_runs: update
14+
max_concurrent_runs: replace
15+
1416

1517

1618
=== Changes in job1.yml

acceptance/bundle/config-remote-sync/multiple_resources/output.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ Deployment complete!
88
Detected changes in 2 resource(s):
99

1010
Resource: resources.jobs.job_one
11-
max_concurrent_runs: update
12-
tags: skip
11+
max_concurrent_runs: replace
12+
tags: add
13+
1314
Resource: resources.jobs.job_two
14-
max_concurrent_runs: update
15-
tags: skip
15+
max_concurrent_runs: replace
16+
tags: add
17+
1618

1719

1820
=== Configuration changes

acceptance/bundle/config-remote-sync/output_json/output.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ Deployment complete!
1414
"changes": {
1515
"resources.jobs.test_job": {
1616
"max_concurrent_runs": {
17-
"action": "update",
18-
"old": 1,
19-
"new": 1,
20-
"remote": 3
17+
"operation": "replace",
18+
"value": 3
2119
},
2220
"tags": {
23-
"action": "skip",
24-
"reason": "server_side_default",
25-
"remote": {
21+
"operation": "add",
22+
"value": {
2623
"env": "test"
2724
}
2825
}

acceptance/bundle/config-remote-sync/output_no_changes/output.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ Deploying resources...
33
Updating deployment state...
44
Deployment complete!
55

6-
=== Check for changes immediately after deploymentNo changes detected.
6+
=== Check for changes immediately after deployment
7+
No changes detected.
78

89

9-
=== Text outputNo changes detected.
10+
=== Text output
11+
No changes detected.
1012

1113

12-
=== JSON output{
14+
=== JSON output
15+
{
1316
"files": null,
1417
"changes": {}
1518
}

acceptance/bundle/config-remote-sync/output_no_changes/script

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ touch dummy.whl
66
$CLI bundle deploy
77

88
title "Check for changes immediately after deployment"
9+
echo
910
$CLI bundle config-remote-sync
1011

1112
title "Text output"
13+
echo
1214
$CLI bundle config-remote-sync | contains.py "No changes detected"
1315

1416
title "JSON output"
17+
echo
1518
$CLI bundle config-remote-sync -o json > out.json
1619
cat out.json

0 commit comments

Comments
 (0)