-
Notifications
You must be signed in to change notification settings - Fork 216
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
Open
scott-mead-db
wants to merge
4
commits into
databricks:main
Choose a base branch
from
scott-mead-db:postgres-create-branch-ttl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3f61394
postgres create-branch: add --ttl and --no-expiry flags
scott-mead-db c16a3d1
Merge branch 'main' into postgres-create-branch-ttl
scott-mead-db 4fea12e
postgres create-branch: address review on --json handling
scott-mead-db fa135a2
postgres create-branch: add unit case for --no-expiry + --json conflict
scott-mead-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
2
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.
Oops, something went wrong.
99 changes: 99 additions & 0 deletions
99
acceptance/cmd/workspace/postgres/create-branch/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
| 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 | ||
|
|
||
|
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 | ||
|
|
||
|
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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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\":\"\"}}'?Uh oh!
There was an error while loading. Please reload this page.
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.
The SDK will error out with: Error: invalid character 't' after top-level value