databricks-cli/bundle
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
..
apps Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
artifacts Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
config Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
deploy Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
docsgen Populate missing bundle config reference doc descriptions and fix resource reference doc template (#2314) 2025-02-24 18:59:12 +00:00
env Remove support for DATABRICKS_BUNDLE_INCLUDES (#1317) 2024-03-27 10:13:54 +00:00
internal build(deps): bump github.com/databricks/databricks-sdk-go from 0.57.0 to 0.58.1 (#2357) 2025-02-25 11:20:29 +00:00
libraries Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
metadata Make `file_path` and `artifact_path` fields consistent with json tag (#987) 2023-11-15 13:37:26 +00:00
paths Fixed adding /Workspace prefix for resource paths (#1866) 2024-10-30 17:34:11 +00:00
permissions Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
phases Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
render Use CreatePipeline instead of PipelineSpec for resources.Pipeline struct (#2287) 2025-02-07 17:22:51 +00:00
resources Use CreatePipeline instead of PipelineSpec for resources.Pipeline struct (#2287) 2025-02-07 17:22:51 +00:00
run Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
schema build(deps): bump github.com/databricks/databricks-sdk-go from 0.57.0 to 0.58.1 (#2357) 2025-02-25 11:20:29 +00:00
scripts Add acceptance test for 'experimental.scripts' (#2240) 2025-01-27 15:28:33 +00:00
tests Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
trampoline Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
bundle.go Set bundle auth configuration in command context (#2195) 2025-01-29 11:02:08 +00:00
bundle_read_only.go Properly read Git metadata when running inside workspace (#1945) 2024-12-05 10:13:13 +00:00
bundle_test.go Enable testifylint and fix the issues (#2065) 2025-01-02 12:03:41 +01:00
context.go Rename variable `bundle -> b` (#989) 2023-11-15 14:03:36 +00:00
context_test.go Enable testifylint and fix the issues (#2065) 2025-01-02 12:03:41 +01:00
mutator.go Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
mutator_read_only.go Always print warnings and errors; clean up format (#2213) 2025-02-07 11:29:40 +00:00
mutator_test.go Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390) 2025-02-27 11:41:58 +00:00
parallel.go Added validate mutator to surface additional bundle warnings (#1352) 2024-04-18 15:13:16 +00:00
parallel_test.go Fix flaky tests for the parallel mutator (#1426) 2024-05-13 12:16:43 +00:00
root.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
root_test.go Enable gofumpt and goimports in golangci-lint (#1999) 2024-12-12 10:28:42 +01:00