Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/cli/postgres-create-branch-ttl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added `--ttl` and `--no-expiry` flags to `databricks postgres create-branch` so a branch's expiration can be set without hand-writing a `--json` spec. `--ttl` accepts the REST API duration form (`604800s`), a Go duration (`168h`), or day/week units (`7d`, `3w`); `--no-expiry` creates a branch that never expires. One of `--ttl`, `--no-expiry`, or a spec expiration in `--json` is required.
2 changes: 2 additions & 0 deletions acceptance/cmd/workspace/postgres/create-branch/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 99 additions & 0 deletions acceptance/cmd/workspace/postgres/create-branch/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@

=== Set up the parent project
=== create-branch --ttl: API (604800s), Go (168h) and day (7d) forms all go on the wire as seconds
=== create-branch --no-expiry
=== create-branch --ttl combined with a --json spec: the flag's ttl survives the json merge
=== the pre-existing flags still work alongside --ttl: --name (body), --replace-existing (query), --timeout (wait)
=== the --no-wait path still works alongside --no-expiry
=== An expiration is required: no flag fails before any API call (no request recorded)
=== Conflicting flags fail before any API call (no request recorded)
=== --no-expiry with a --json that also sets spec.no_expiry is a conflict, not a silent override
=== Malformed --json fails client-side
=== An empty spec.ttl in --json fails client-side
=== Recorded create-branch request bodies{
"method": "POST",
"path": "/api/2.0/postgres/projects/acc-proj/branches",
"q": {
"branch_id": "branch-ttl-api"
},
"body": {
"spec": {
"ttl": "604800s"
}
}
}
{
"method": "POST",
"path": "/api/2.0/postgres/projects/acc-proj/branches",
"q": {
"branch_id": "branch-ttl-go"
},
"body": {
"spec": {
"ttl": "604800s"
}
}
}
{
"method": "POST",
"path": "/api/2.0/postgres/projects/acc-proj/branches",
"q": {
"branch_id": "branch-ttl-days"
},
"body": {
"spec": {
"ttl": "604800s"
}
}
}
{
"method": "POST",
"path": "/api/2.0/postgres/projects/acc-proj/branches",
"q": {
"branch_id": "branch-noexp"
},
"body": {
"spec": {
"no_expiry": true
}
}
}
{
"method": "POST",
"path": "/api/2.0/postgres/projects/acc-proj/branches",
"q": {
"branch_id": "branch-mix"
},
"body": {
"spec": {
"source_branch": "projects/acc-proj/branches/production",
"ttl": "604800s"
}
}
}
{
"method": "POST",
"path": "/api/2.0/postgres/projects/acc-proj/branches",
"q": {
"branch_id": "branch-flags",
"replace_existing": "true"
},
"body": {
"name": "display-name",
"spec": {
"ttl": "604800s"
}
}
}
{
"method": "POST",
"path": "/api/2.0/postgres/projects/acc-proj/branches",
"q": {
"branch_id": "branch-nowait"
},
"body": {
"spec": {
"no_expiry": true
}
}
}
37 changes: 37 additions & 0 deletions acceptance/cmd/workspace/postgres/create-branch/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
title "Set up the parent project"
$CLI postgres create-project acc-proj > LOG.setup 2>&1

title "create-branch --ttl: API (604800s), Go (168h) and day (7d) forms all go on the wire as seconds"
$CLI postgres create-branch projects/acc-proj branch-ttl-api --ttl 604800s > LOG.ttl-api 2>&1
$CLI postgres create-branch projects/acc-proj branch-ttl-go --ttl 168h > LOG.ttl-go 2>&1
$CLI postgres create-branch projects/acc-proj branch-ttl-days --ttl 7d > LOG.ttl-days 2>&1

title "create-branch --no-expiry"
$CLI postgres create-branch projects/acc-proj branch-noexp --no-expiry > LOG.noexp 2>&1

title "create-branch --ttl combined with a --json spec: the flag's ttl survives the json merge"
$CLI postgres create-branch projects/acc-proj branch-mix --ttl 604800s --json '{"spec":{"source_branch":"projects/acc-proj/branches/production"}}' > LOG.mix 2>&1

title "the pre-existing flags still work alongside --ttl: --name (body), --replace-existing (query), --timeout (wait)"
$CLI postgres create-branch projects/acc-proj branch-flags --ttl 168h --name display-name --replace-existing --timeout 60s > LOG.flags 2>&1

title "the --no-wait path still works alongside --no-expiry"
$CLI postgres create-branch projects/acc-proj branch-nowait --no-expiry --no-wait > LOG.nowait 2>&1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens if you pass something like --json '{\"spec\":{\"ttl\":\"\"}}'?

@scott-mead-db scott-mead-db Aug 24, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The SDK will error out with: Error: invalid character 't' after top-level value

title "An expiration is required: no flag fails before any API call (no request recorded)"
musterr $CLI postgres create-branch projects/acc-proj branch-none &> LOG.required

Comment thread
scott-mead-db marked this conversation as resolved.
title "Conflicting flags fail before any API call (no request recorded)"
musterr $CLI postgres create-branch projects/acc-proj branch-conflict --ttl 1h --no-expiry &> LOG.conflict

Comment thread
scott-mead-db marked this conversation as resolved.
title "--no-expiry with a --json that also sets spec.no_expiry is a conflict, not a silent override"
musterr $CLI postgres create-branch projects/acc-proj branch-both --no-expiry --json '{"spec":{"no_expiry":false}}' &> LOG.both

title "Malformed --json fails client-side"
musterr $CLI postgres create-branch projects/acc-proj branch-badjson --json 'not json' &> LOG.badjson

title "An empty spec.ttl in --json fails client-side"
musterr $CLI postgres create-branch projects/acc-proj branch-emptyttl --json '{"spec":{"ttl":""}}' &> LOG.emptyttl

title "Recorded create-branch request bodies"
print_requests.py //branches
4 changes: 4 additions & 0 deletions acceptance/cmd/workspace/postgres/create-branch/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RecordRequests = true

# Not a bundle command; pin a single engine so it runs once.
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]
Loading
Loading