databricks-cli/integration/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
..
bundles Add a unique schema for recreate pipeline test (#2159) 2025-01-15 17:22:45 +00:00
testdata Fixed an apps message order and added output test (#2174) 2025-01-17 14:42:39 +00:00
apps_test.go Fixed an apps message order and added output test (#2174) 2025-01-17 14:42:39 +00:00
artifacts_test.go Add validation mutator for volume `artifact_path` (#2050) 2025-01-02 17:23:15 +05:30
basic_test.go Move integration test helpers to `integration/internal` (#2022) 2024-12-17 08:45:58 +01:00
bind_resource_test.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
clusters_test.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
dashboards_test.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
deploy_test.go Enable testifylint and fix the issues (#2065) 2025-01-02 12:03:41 +01:00
deploy_then_remove_resources_test.go Move integration test helpers to `integration/internal` (#2022) 2024-12-17 08:45:58 +01:00
deploy_to_shared_test.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
deployment_state_test.go Move integration test helpers to `integration/internal` (#2022) 2024-12-17 08:45:58 +01:00
destroy_test.go Enable testifylint and fix the issues (#2065) 2025-01-02 12:03:41 +01:00
empty_bundle_test.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
environments_test.go Move integration test helpers to `integration/internal` (#2022) 2024-12-17 08:45:58 +01:00
generate_job_test.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
generate_pipeline_test.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
helpers_test.go Refactor `bundle init` (#2074) 2025-01-20 12:09:28 +00:00
init_default_python_test.go Use regular expressions for testdiff replacements (#2151) 2025-01-15 12:15:23 +01:00
init_test.go Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
job_metadata_test.go Move integration test helpers to `integration/internal` (#2022) 2024-12-17 08:45:58 +01:00
local_state_staleness_test.go Move integration test helpers to `integration/internal` (#2022) 2024-12-17 08:45:58 +01:00
python_wheel_test.go Remove superfluous helper (#2028) 2024-12-17 17:34:09 +00:00
spark_jar_test.go Skip job runs during integration testing for PRs (#2024) 2024-12-17 17:16:58 +00:00
validate_test.go Remove calls to `testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")` (#2014) 2024-12-13 16:09:51 +00:00