databricks-cli/bundle/run
Denis Bilenko e2db0cd0e2
Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390)
## Changes
- Instead of constructing chains of mutators and then executing them,
execute them directly.
- Remove functionality related to chain-building: Seq, If, Defer,
newPhase, logString.
- Phases become functions that apply the changes directly rather than
construct mutator chains that will be called later.
- Add a helper ApplySeq to call multiple mutators, use it where
Apply+Seq were used before.

This is intended to be a refactoring without functional changes, but
there are a few behaviour changes:
- Since defer() is used to call unlock instead of bundle.Defer()
unlocking will now happen even in case of panics.
- In --debug, the phase names are are still logged once before start of
the phase but each entry no longer has 'seq' or phase name in it.
- The message "Deployment complete!" was printed even if
terraform.Apply() mutator had an error. It no longer does that.

## Motivation

The use of the chains was necessary when mutators were returning a list
of other mutators instead of calling them directly. But that has since
been removed, so now the chain machinery have no purpose anymore.

Use of direct functions simplifies the logic and makes bugs more
apparent and easy to fix.

Other improvements that this unlocks:
- Simpler stacktraces/debugging (breakpoints).
- Use of functions with narrowly scoped API: instead of mutators that
receive full bundle config, we can use focused functions that only deal
with sections they care about prepareGitSettings(currentGitSection) ->
updatedGitSection. This makes the data flow more apparent.
- Parallel computations across mutators (within phase): launch
goroutines fetching data from APIs at the beggining, process them once
they are ready.

## Tests
Existing tests.
2025-02-27 11:41:58 +00:00
..
output Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
progress Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
app.go Retry app deployment if there is an active deployment in progress (#2153) 2025-01-15 12:51:06 +01:00
app_test.go Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
args.go Processing and completion of positional args to bundle run (#1120) 2024-04-22 11:50:13 +00:00
args_test.go Processing and completion of positional args to bundle run (#1120) 2024-04-22 11:50:13 +00:00
job.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
job_args.go Enable gofumpt and goimports in golangci-lint (#1999) 2024-12-12 10:28:42 +01:00
job_args_test.go Processing and completion of positional args to bundle run (#1120) 2024-04-22 11:50:13 +00:00
job_options.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
job_options_test.go Group bundle run flags by job and pipeline types (#1174) 2024-02-06 14:51:02 +00:00
job_test.go Refactor `bundle init` (#2074) 2025-01-20 12:09:28 +00:00
options.go Make sure grouped flags are added to the command flag set (#1180) 2024-02-07 10:27:13 +00:00
pipeline.go Use CreatePipeline instead of PipelineSpec for resources.Pipeline struct (#2287) 2025-02-07 17:22:51 +00:00
pipeline_options.go Add `--validate-only` flag to run validate-only pipeline update (#1251) 2024-03-04 08:38:32 +00:00
pipeline_options_test.go Add `--validate-only` flag to run validate-only pipeline update (#1251) 2024-03-04 08:38:32 +00:00
pipeline_test.go Refactor `bundle init` (#2074) 2025-01-20 12:09:28 +00:00
runner.go Added support for Databricks Apps in DABs (#1928) 2025-01-13 16:43:48 +00:00
runner_test.go Reuse resource resolution code for the run command (#1858) 2024-10-24 13:24:30 +00:00