-
Notifications
You must be signed in to change notification settings - Fork 214
postgres create-branch: add --ttl and --no-expiry flags #6313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
|
|
||
| === 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) | ||
| === 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 | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 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 | ||
|
|
||
| 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 | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. coudl you add a test for `create-branch projects/p b --json 'not json' |
||
| 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 | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a tst when both passed like |
||
| title "Recorded create-branch request bodies" | ||
| print_requests.py //branches | ||
| 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"] |
There was a problem hiding this comment.
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\":\"\"}}'?