databricks-cli/bundle/config
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
..
interpolation Update variable regex to support hyphens (#503) 2023-06-23 12:56:54 +02:00
mutator Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
resources Update to Go SDK v0.8.0 (#351) 2023-04-21 10:30:20 +02:00
testdata First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
variable Add config environment support for variable overriding (#383) 2023-05-15 14:07:18 +02:00
artifact.go Added support for build command chaining and error on missing wheel (#607) 2023-07-26 12:58:52 +00:00
bundle.go Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
environment.go Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
git.go Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
lock.go Acquire lock prior to deploy (#270) 2023-03-22 16:37:26 +01:00
lock_test.go Acquire lock prior to deploy (#270) 2023-03-22 16:37:26 +01:00
resources.go Rename bricks -> databricks (#389) 2023-05-16 18:35:39 +02:00
resources_test.go Rename bricks -> databricks (#389) 2023-05-16 18:35:39 +02:00
root.go Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
root_test.go First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
workspace.go Extend deployment mode support (#577) 2023-07-30 07:19:49 +00:00