databricks-cli/bundle
Andrew Nester 180dfc9a40
Added ability for deferred mutator execution (#380)
## Changes
Added `DeferredMutator` and `bundle.Defer` function which allows to
always execute some mutators either in the end of execution chain or
after error occurs in the middle of execution chain.

Usage as follows:

```
deferredMutator := bundle.Defer([]bundle.Mutator{
    lock.Acquire()
    transform.DoSomething(),
    //...
}, []bundle.Mutator{
    lock.Release(),
})
```
In such case `lock.Release()` will always be executed: either when all
operations above succeed or when any of them fails

## Tests
Before the change

```
andrew.nester@HFW9Y94129 multiples-tasks % bricks bundle deploy
Starting upload of bundle files
Uploaded bundle files at /Users/andrew.nester@databricks.com/.bundle/simple-task/development/files!

Error: terraform not initialized
andrew.nester@HFW9Y94129 multiples-tasks % bricks bundle deploy
Error: deploy lock acquired by andrew.nester@databricks.com at 2023-05-10 16:41:22.902659 +0200 CEST. Use --force to override

```

After the change
```
andrew.nester@HFW9Y94129 multiples-tasks % bricks bundle deploy 
Starting upload of bundle files
Uploaded bundle files at /Users/andrew.nester@databricks.com/.bundle/simple-task/development/files!

Error: terraform not initialized
andrew.nester@HFW9Y94129 multiples-tasks % bricks bundle deploy
Starting upload of bundle files
Uploaded bundle files at /Users/andrew.nester@databricks.com/.bundle/simple-task/development/files!

Error: terraform not initialized
```
2023-05-16 18:01:50 +02:00
..
artifacts Make all workspace paths string fields (#327) 2023-04-12 16:54:36 +02:00
config Add config environment support for variable overriding (#383) 2023-05-15 14:07:18 +02:00
deploy Do not truncate local state file when pulling remote changes (#382) 2023-05-16 17:02:33 +02:00
deployer Acquire lock prior to deploy (#270) 2023-03-22 16:37:26 +01:00
internal/tf Update Terraform provider schema structs (#265) 2023-03-20 17:22:55 +01:00
phases Added ability for deferred mutator execution (#380) 2023-05-16 18:01:50 +02:00
run Fixed printing the tasks in job output in DAG execution order (#377) 2023-05-08 16:35:47 +02:00
schema Add top level docs for bundle json schema (#313) 2023-04-12 21:43:53 +02:00
tests Add config environment support for variable overriding (#383) 2023-05-15 14:07:18 +02:00
bundle.go Store relative path to configuration file for every resource (#322) 2023-04-12 16:17:13 +02:00
bundle_test.go Store relative path to configuration file for every resource (#322) 2023-04-12 16:17:13 +02:00
context.go Make sync command work in bundle context; reorder args (#207) 2023-02-20 11:33:30 +01:00
context_test.go Add command that writes the materialized bundle configuration to stdout (#95) 2022-11-21 15:39:53 +01:00
deferred.go Added ability for deferred mutator execution (#380) 2023-05-16 18:01:50 +02:00
deferred_test.go Added ability for deferred mutator execution (#380) 2023-05-16 18:01:50 +02:00
mutator.go Include mutator name in logging context (#271) 2023-03-22 15:54:10 +01:00
mutator_test.go Move mutator interface to top level bundle package (#105) 2022-11-28 10:59:43 +01:00
root.go Add function to opportunistically load a bundle (#180) 2023-01-27 16:57:39 +01:00
root_test.go Add function to opportunistically load a bundle (#180) 2023-01-27 16:57:39 +01:00