databricks-cli/bundle/config/interpolation
stikkireddy 3c1e69a064
Update variable regex to support hyphens (#503)
## Changes

Modified interpolation logic to use:
`\$\{([a-zA-Z]+([-_]*[a-zA-Z0-9]+)*(\.[a-zA-Z]+([-_]*[a-zA-Z0-9]+)*)*)\}`

**Edit**: Suggested by @pietern
`\$\{([a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*)*)\}`
to be more selective and not allow consequent hyphens or underscores to
make the keys more readable.

Explanation:
1. All interpolation starts with `${` and ends with `}`
2. All interpolated locations are split by by `.`
3. All sections are expected to start with a alphabet `[a-zA-Z]`; no
numbers, hyphens or underscores.
4. All sections are expected to end with an alphanumeric `[a-zA-Z0-9]`
no hyphens or underscores

This change allows the current interpolation to be more permissive.

**Note** it does break backwards compatibility because `[a-zA-Z] !=
[\w]`. `\w` includes alphanumeric and underscores. `\w = [a-zA-Z0-9_]`

## Tests
There are two tests with examples of valid and invalid interpolation and
a test to validate expansion.
2023-06-23 12:56:54 +02:00
..
interpolation.go Update variable regex to support hyphens (#503) 2023-06-23 12:56:54 +02:00
interpolation_test.go Update variable regex to support hyphens (#503) 2023-06-23 12:56:54 +02:00
lookup.go Allow multiple lookup functions for interpolation (#128) 2022-12-12 10:48:52 +01:00
lookup_test.go Allow multiple lookup functions for interpolation (#128) 2022-12-12 10:48:52 +01:00
setter.go Parameterize interpolation function (#117) 2022-12-01 22:38:49 +01:00