databricks-cli/cmd/bundle
shreyas-goenka 41a21af556
Refactor `bundle init` (#2074)
## Summary of changes
This PR introduces three new abstractions: 
1. `Resolver`: Resolves which reader and writer to use for a template.
2. `Writer`: Writes a template project to disk. Prompts the user if
necessary.
3. `Reader`: Reads a template specification from disk, built into the
CLI or from GitHub.

Introducing these abstractions helps decouple reading a template from
writing it. When I tried adding telemetry for the `bundle init` command,
I noticed that the code in `cmd/init.go` was getting convoluted and hard
to test. A future change could have accidentally logged PII when a user
initialised a custom template.

Hedging against that risk is important here because we use a generic
untyped `map<string, string>` representation in the backend to log
telemetry for the `databricks bundle init`. Otherwise, we risk
accidentally breaking our compliance with our centralization
requirements.

### Details

After this PR there are two classes of templates that can be
initialized:
1. A `databricks` template: This could be a builtin template or a
template outside the CLI like mlops-stacks, which is still owned and
managed by Databricks. These templates log their telemetry arguments and
template name.
2. A `custom` template: These are templates created by and managed by
the end user. In these templates we do not log the template name and
args. Instead a generic placeholder string of "custom" is logged in our
telemetry system.

NOTE: The functionality of the `databricks bundle init` command remains
the same after this PR. Only the internal abstractions used are changed.

## Tests
New unit tests. Existing golden and unit tests. Also a fair bit of
manual testing.
2025-01-20 12:09:28 +00:00
..
debug Enable errcheck everywhere and fix or silent remaining issues (#1987) 2024-12-11 13:26:00 +01:00
deployment Make bundle loaders return diagnostics (#1319) 2024-03-28 10:32:34 +00:00
generate Include help output for bundle commands in acceptance tests (#2178) 2025-01-17 14:52:53 +00:00
utils Improve `bundle validate` output (#1532) 2024-07-01 09:01:10 +00:00
bundle.go Add command to open a resource in the browser (#1846) 2024-10-24 12:20:33 +00:00
debug.go Add `bundle debug terraform` command (#1294) 2024-04-02 12:56:27 +00:00
deploy.go Add validation mutator for volume `artifact_path` (#2050) 2025-01-02 17:23:15 +05:30
destroy.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
generate.go Added support for Databricks Apps in DABs (#1928) 2025-01-13 16:43:48 +00:00
init.go Refactor `bundle init` (#2074) 2025-01-20 12:09:28 +00:00
launch.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
open.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
run.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
schema.go Make bundle JSON schema modular with `$defs` (#1700) 2024-09-10 13:55:18 +00:00
summary.go Enable errcheck everywhere and fix or silent remaining issues (#1987) 2024-12-11 13:26:00 +01:00
sync.go Add "output" flag to the bundle sync command (#1853) 2024-10-23 11:08:12 +00:00
test.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
validate.go Log warnings to stderr for "bundle validate -o json" (#2109) 2025-01-10 08:51:59 +00:00
variables.go Added `bundle deployment bind` and `unbind` command (#1131) 2024-02-14 18:04:45 +00:00