Repository navigation
Add default-bare template and bundle generate --init-bare - #7355
janniklasrose wants to merge 18 commits into
Conversation
Introduce a minimal built-in bundle template designed for zero-to-import workflows, containing only the essential directory structure (resources/, src/, .gitignore, databricks.yml, README). Register it as 'default-bare' alongside other templates and surface it in bundle init help text. Refactor init.go flag handling to use GetString() and extract Resolver construction into a helper function. Co-authored-by: Isaac <no-reply@databricks.com>
Add an explicit --init-bare flag to 'bundle generate' that automatically initializes a bare bundle skeleton when one doesn't exist. Create shared generate plumbing (ensureGenerateBundle, initializeBareBundle) that handles the choice between bundle-aware and auth-only modes. Update job generator to use the new helper. When --init-bare is used without an existing bundle, materialize the default-bare template with a derived project name before proceeding with generation. Co-authored-by: Isaac <no-reply@databricks.com>
Create a parity test that documents which bundle resource types have generate support implemented and which ones don't. This serves as a checklist and commit point: new resource types added to bundle/config/resources.go should either get generate support or be explicitly listed as unsupported. Currently supported: job, pipeline, dashboard, alert, app, genie_space. Co-authored-by: Isaac <no-reply@databricks.com>
Regenerate bundle generate help output to include --init-bare flag documentation. Add acceptance test for the new default-bare template that verifies the template materializes correctly with proper directory structure for resources and src. Co-authored-by: Isaac <no-reply@databricks.com>
Document the new --init-bare flag for bundle generate in the changelog. Co-authored-by: Isaac <no-reply@databricks.com>
Update test expectations in template_test.go to reflect the new default-bare template addition. Include it in help descriptions, options, and template availability checks. Co-authored-by: Isaac <no-reply@databricks.com>
Make parity_test.go real by enumerating all bundle resource types and validating that each is either supported with a generate command or in an explicit unsupported allowlist. This catches when new resources are added without corresponding generator support. Wire --init-bare into all generate commands (job, pipeline, alert, app) by using ensureGenerateBundle helper. Add flag validation to reject incompatible combinations with --init-bare before materialization: - --bind (no deployment state without existing bundle) - dashboard --resource (requires existing bundle resources) - dashboard --watch (requires existing bundle resources to watch) Co-authored-by: Isaac <no-reply@databricks.com>
Update help snapshots to include --init-bare flag documentation and updated descriptions for all bundle generate subcommands (job, pipeline, dashboard, app, alert) and bundle init command. Co-authored-by: Isaac <no-reply@databricks.com>
…tion tests - Add ensureGenerateBundle to dashboard and genie_space generators to enable --init-bare flag and properly validate incompatible flag combinations - Add PersistentPreRunE to generate command to initialize workspace client before running subcommands (required for template materialization) - Fix InitContext duplicate initialization in job.go - Add acceptance test for --init-bare --bind rejection (negative case) that verifies error is thrown before any bundle materialization - All generators now support --init-bare for bare bundle initialization Co-authored-by: Isaac <no-reply@databricks.com>
The PersistentPreRunE for bundle generate command was not being set properly, causing cmdio to be missing from the context when generate subcommands tried to use it for logging diagnostics. This led to panics when downloader.FlushToDisk tried to call cmdio.LogString. The fix: - Removed PersistentPreRunE from bundle generate command to avoid overriding root's initialization - Added ensureWorkspaceClient function that is called from each generate subcommand's RunE to initialize workspace client when needed - Modified root.MustWorkspaceClient to check if logdiag is already initialized before calling logdiag.InitContext to avoid double-initialization panic This ensures both cmdio (from root's PersistentPreRunE) and workspace client are properly initialized in the context for template materialization. Co-authored-by: Isaac <no-reply@databricks.com>
Records the plan for the bare template, --init-bare and the resource families, plus this branch's status and open issues. Co-authored-by: Isaac <no-reply@databricks.com>
# Conflicts: # acceptance/bundle/help/bundle-init/output.txt # cmd/bundle/init.go
…up front Every generate subcommand now goes through configureBundle, which sets up logdiag, loads the bundle, and only when none exists and --init-bare is set materializes the default-bare template and loads that. Flags that need an existing bundle (--bind, --resource, --watch) are rejected before anything is written to disk. This replaces the earlier helper that initialized logdiag and loaded the bundle up to three times per invocation. MustWorkspaceClient skips logdiag.InitContext when a caller has already set it up, since the bare path calls it from inside RunE for template helpers like workspace_host. Co-authored-by: Isaac <no-reply@databricks.com>
The template no longer nests its files under a project directory, so `bundle init default-bare --output-dir .` and `bundle generate --init-bare` both produce a bundle right where the user is. The bundle is still named by the project_name input, which --init-bare derives from the directory name. Also uses the Declarative Automation Bundle wording that main adopted for the other templates. Co-authored-by: Isaac <no-reply@databricks.com>
The previous test compared two hand-written maps, so a new resource type could never fail it. It now reads the generate subcommands from the command tree and the resource groups from config.SupportedResources, and fails when a group is neither generated nor explicitly listed as unsupported. Co-authored-by: Isaac <no-reply@databricks.com>
job_init_bare covers the happy path: a bare bundle named after the directory plus the generated job. init_bare_rejected_flags covers the hint printed without --init-bare and the rejection of --bind, --resource and --watch before anything is written. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
|
Commit: Regression test reportSelected 8 changed tests (limit=20, 0 not selected) 15 tests: regression=15 unreleased=0 coverage=0 failing=0
TestAccept/bundle/generate/init_bare_rejected_flags/DMS=: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/generate/init_bare_rejected_flags/DMS=true: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/generate/job_init_bare/DMS=: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/generate/job_init_bare/DMS=true: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): TestAccept/bundle/help/bundle-generate-dashboard/DMS=: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/help/bundle-generate-dashboard/DMS=true: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/help/bundle-generate-job/DMS=: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/help/bundle-generate-job/DMS=true: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/help/bundle-generate-pipeline/DMS=: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/help/bundle-generate-pipeline/DMS=true: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): TestAccept/bundle/help/bundle-generate/DMS=: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/help/bundle-generate/DMS=true: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/help/bundle-init/DMS=: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/help/bundle-init/DMS=true: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) TestAccept/bundle/templates/default-bare/minimal/DMS=: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌main (e1b8c92): latest (v1.24.0): same output as main (e1b8c92) |
Integration test reportCommit: 7507ca6
Top 3 slowest tests (at least 2 minutes):
|
|
Closing: --init-bare / default-bare is not wanted; bundle init empty covers it. The generate-for-all-resources work continues on a fresh branch. |
Changes
Lets users start a bundle from an existing workspace resource without writing a
databricks.ymlfirst.default-bare:databricks.yml(onedevtarget),resources/,src/,.gitignore, and a short README. It renders directly into the output directory rather than a project subdirectory, sobundle init default-bare --output-dir .and the flag below both create the bundle in place.--init-bareonbundle generate. When no bundle is found, the generate subcommand materializesdefault-barein the current directory (named after it) and then generates into it. Without the flag the command now prints a hint pointing at the template and the flag instead of the raw "no databricks.yml" error.--bind, dashboard and Genie space--resource/--watch) are rejected before anything is written to disk.configureBundlehelper incmd/bundle/generate/init_bare.go, which sets up diagnostics and loads the bundle once.root.MustWorkspaceClientnow skipslogdiag.InitContextwhen a caller has already set it up; the bare path needs it from insideRunEso the template can renderworkspace_host.cmd/bundle/generate_test.gochecks every resource group inconfig.SupportedResources()either has a generate subcommand or is listed as unsupported, so new resource types get an explicit decision.Why a new template instead of
default-minimaldefault-minimal(aliasempty) still renders from the shareddefaulttree: with languageskipit produces.vscode/,AGENTS.md,fixtures/, and a README aimed at project development. For importing existing resources that is noise, and the shared template keeps growing.default-bareis five files and is the only template a generate subcommand needs to know about.Follow-ups (not in this PR)
generateUnsupportedin the parity test is the to-do list.Why
bundle generatewas only usable from inside an existing bundle, and none of the init templates produced a skeleton small enough to be a sensible starting point for importing resources.Tests
acceptance/bundle/generate/job_init_bare: happy path, bundle named after the directory plus the generated job and notebook.acceptance/bundle/generate/init_bare_rejected_flags: hint without the flag;--bind,--resource, and--watchrejected with no files written.acceptance/bundle/templates/default-bare/minimal:bundle init default-barefollowed bybundle validate.bundle generate, its subcommands, andbundle initregenerated.go test ./cmd/bundle/... ./libs/template/and thebundle/generate,bundle/templates/default-bare,bundle/helpacceptance suites pass locally.This pull request and its description were written by Isaac.