databricks-cli/bundle/config/mutator
Lennart Kats (databricks) 433f401c83
Add validation for Git settings in bundles (#578)
## Changes

This checks whether the Git settings are consistent with the actual Git
state of a source directory.

(This PR adds to https://github.com/databricks/cli/pull/577.) 

Previously, we would silently let users configure their Git branch to
e.g. `main` and deploy with that metadata even if they were actually on
a different branch.

With these changes, the following config would result in an error when
deployed from any other branch than `main`:

```
bundle:
  name: example

workspace:
  git:
    branch: main

environments:
  ...
```

> not on the right Git branch:
>   expected according to configuration: main
>   actual: my-feature-branch

It's not very useful to set the same branch for all environments,
though. For development, it's better to just let the CLI auto-detect the
right branch. Therefore, it's now possible to set the branch just for a
single environment:

```
bundle:
  name: example 2

environments:
  development:
    default: true

  production:
    # production can only be deployed from the 'main' branch
    git:
      branch: main
```

Adding to that, the `mode: production` option actually checks that users
explicitly set the Git branch as seen above. Setting that branch helps
avoid mistakes, where someone accidentally deploys to production from
the wrong branch. (I could see us offering an escape hatch for that in
the future.)

# Testing

Manual testing to validate the experience and error messages. Automated
unit tests.

---------

Co-authored-by: Fabian Jakobs <fabian.jakobs@databricks.com>
2023-07-30 12:44:33 +00:00
..
default_environment.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
default_environment_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
default_workspace_paths.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
default_workspace_paths_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
default_workspace_root.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
default_workspace_root_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
expand_workspace_root.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
expand_workspace_root_test.go Extend deployment mode support (#577) 2023-07-30 07:19:49 +00:00
load_git_details.go Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
mutator.go Require include glob patterns to be explicitly defined (#602) 2023-07-25 10:00:46 +02:00
override_compute.go Add development runs (#522) 2023-07-12 08:51:54 +02:00
override_compute_test.go Add development runs (#522) 2023-07-12 08:51:54 +02:00
populate_current_user.go Extend deployment mode support (#577) 2023-07-30 07:19:49 +00:00
populate_current_user_test.go Extend deployment mode support (#577) 2023-07-30 07:19:49 +00:00
process_environment_mode.go Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
process_environment_mode_test.go Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
process_include.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
process_include_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
process_root_includes.go First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
process_root_includes_test.go First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
select_default_environment.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
select_default_environment_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
select_environment.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
select_environment_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
set_variables.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
set_variables_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
translate_paths.go Disallow notebooks in paths where files are expected (#573) 2023-07-12 12:25:00 +00:00
translate_paths_test.go Disallow notebooks in paths where files are expected (#573) 2023-07-12 12:25:00 +00:00
validate_git_details.go Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
validate_git_details_test.go Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00