template: git-backed deployment in scaffolded databricks.yml (proposal) - #556
template: git-backed deployment in scaffolded databricks.yml (proposal)#556atreyadbrx wants to merge 3 commits into
Conversation
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>
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>
There was a problem hiding this comment.
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.
| app: | ||
| name: "{{.projectName}}" | ||
| description: "{{.appDescription}}" | ||
| {{- if .git.url}} |
There was a problem hiding this comment.
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.)
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 initruns 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.tmplreplaces the commentedgit_repository/git_sourceexample with a conditional block: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 inittime and derives the origin URL, provider (gitHub/gitLab/bitbucketCloud/azureDevOpsServices), current branch, and repo-relative source path. Detection is conservative: it falls back tosource_code_pathwhen 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 initproduces a git-backeddatabricks.ymlwith zero extra steps. Outside a repo, behavior is unchanged.Safe / backward-compatible
source_code_pathorgit_source; the conditional emits exactly one, never both..git.urlempty (missingkey=zero) → theelsebranch keepssource_code_path. So this template works with any CLI version.Questions for the reviewer
apps init?This pull request and its description were written by Isaac.