Skip to content

template: git-backed deployment in scaffolded databricks.yml (proposal) - #556

Draft
atreyadbrx wants to merge 3 commits into
databricks:mainfrom
atreyadbrx:git-backed-app-template
Draft

template: git-backed deployment in scaffolded databricks.yml (proposal)#556
atreyadbrx wants to merge 3 commits into
databricks:mainfrom
atreyadbrx:git-backed-app-template

Conversation

@atreyadbrx

@atreyadbrx atreyadbrx commented Aug 27, 2026

Copy link
Copy Markdown

Proposal: git-backed deployment by default for scaffolded apps

This makes a newly scaffolded AppKit app deploy from its Git repository instead of uploading local files — automatically, whenever databricks apps init runs inside a Git repo with a remote. It's a proposal for discussion; happy to adjust shape/scope.

What changes here (AppKit)

template/databricks.yml.tmpl replaces the commented git_repository/git_source example with a conditional block:

{{- if .git.url}}
      git_repository:
        url: {{.git.url}}
        provider: {{.git.provider}}
      git_source:
        branch: {{.git.branch}}
        source_code_path: {{.git.sourceCodePath}}
{{- else}}
      source_code_path: ./
{{- end}}

What makes it active (paired CLI change)

The template fields are populated by a paired change in the Databricks CLI — databricks/cli#6406 — which detects the Git repo containing the app at apps init time and derives the origin URL, provider (gitHub/gitLab/bitbucketCloud/azureDevOpsServices), current branch, and repo-relative source path. Detection is conservative: it falls back to source_code_path when there's no repo, no origin, an unknown provider host, a detached HEAD, or an out-of-repo destination.

Net effect: git clone <repo> && cd <repo> && databricks apps init produces a git-backed databricks.yml with zero extra steps. Outside a repo, behavior is unchanged.

Safe / backward-compatible

  • Bundle validation requires exactly one of source_code_path or git_source; the conditional emits exactly one, never both.
  • Older CLIs render .git.url empty (missingkey=zero) → the else branch keeps source_code_path. So this template works with any CLI version.
  • Verified: the template renders valid YAML in both branches.

Questions for the reviewer

  1. Is the scaffold template the right home for this, given the detection logic necessarily lives in the CLI's apps init?
  2. Are you comfortable making git-backed the default whenever scaffolding inside a repo with a remote (vs. opt-in)? A deploy still requires the code to be committed and pushed first — the rendered comment says so.
  3. Any concerns with the provider-host mapping or the conservative fallbacks?

This pull request and its description were written by Isaac.

Add a commented git_repository/git_source example to the scaffolded app
bundle so developers can deploy from a Git repository/ref instead of
uploading local files (reproducible, reviewable, roll-back-able). Proposal
to steer AppKit apps toward git-backed deployment; see the PR description
for the fuller direction (making it the default via `apps init` repo
detection, which needs a coupled CLI change).

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: atreyadbrx <atreya.misra@databricks.com>
atreyadbrx and others added 2 commits August 27, 2026 20:31
Replace the commented git_repository/git_source example with a conditional
that the Databricks CLI's `apps init` fills in when scaffolding inside a Git
repository (databricks/cli#6406). When the CLI detects an origin remote it
renders a real git_repository (url + provider) and git_source (branch +
repo-relative source_code_path); otherwise the template keeps
source_code_path, so older CLIs and non-repo scaffolds are unaffected.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: atreyadbrx <atreya.misra@databricks.com>
Git-backing is moving to an explicit opt-in migration for existing apps
(driven by the databricks-apps skill) rather than detection at create time.
Ship the git_repository/git_source block as a commented example that the
migration fills in, instead of rendering it actively from apps init.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: atreyadbrx <atreya.misra@databricks.com>

@pkosiec pkosiec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed with the paired cli#6406 👍

One more for the git-backed comment block: a private repo needs a linked git credential on the workspace for the provider. The scaffold cannot detect visibility, so a private repo without one fails at deploy. We should document it and also support during the E2E flow.

Comment thread template/databricks.yml.tmpl Outdated
app:
name: "{{.projectName}}"
description: "{{.appDescription}}"
{{- if .git.url}}

@pkosiec pkosiec Sep 2, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not safe against a CLI that does not set the git map.

The PR says older CLIs render .git.url empty and fall to the else branch. It is the opposite: with no git key, {{if .git.url}} fails hard ("nil pointer evaluating interface {}.url"). Under missingkey=zero the first lookup (.git) returns a nil interface, then the chained .url panics.

In practice the default path is safe, because cli-compat.json pins each CLI version to a template tag. But --version latest, or an explicit --version <new>, on any pre-#6406 CLI clones this template and breaks.

Have the CLI set git only when detection is active (nil otherwise), and use a single with/else here. That drops the chained field access and reads cleaner:

    {{- with .git}}
          git_repository:
            url: {{.url}}
            provider: {{.provider}}
          git_source:
            branch: {{.branch}}
            source_code_path: {{.sourceCodePath}}
    {{- else}}
          source_code_path: ./
    {{- end}}

with tests the value itself, so a missing or nil git safely takes the else. This needs the CLI to pass git only when active, since a non-empty map is always truthy. (Note: text/template and does not short circuit, so {{if and .git .git.url}} would still error.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants