Repository navigation
Add postgres_data_apis bundle resource #7160
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
Merged
+2,564
−14
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
47bc0d1
Add postgres_data_apis bundle resource
ruslantalpa e78db3d
Match the testserver Data API fake to the real API
ruslantalpa f101965
Detect postgres_data_apis spec drift by reading the spec from status
ruslantalpa 5967cf7
Add PR link to postgres_data_apis changelog entry
ruslantalpa 10b5883
Report status.url from the testserver Data API fake
ruslantalpa 6d5ce39
Declare postgres_data_apis status.url a stable output field
ruslantalpa e6b2aee
Cover bools, durations and openapi_mode in the Data API invariant config
ruslantalpa 3521907
Describe postgres_data_apis and OpenApiMode in the bundle schema
ruslantalpa f72c326
Keep the launchStageOverrides alignment unchanged
ruslantalpa bc1f833
Update changelog entry to link #7160
ruslantalpa 28fa436
Use bash 3.2-compatible redirect in postgres_data_api bind test
ruslantalpa eff01c8
Skip DMS runs for postgres_data_apis until deployment history accepts it
ruslantalpa 6a850e3
Regenerate postgres_data_apis outputs after rebase onto main
ruslantalpa 37c6b26
Skip DMS runs for the postgres_data_api bind test
ruslantalpa 3063db2
Declare the production branch in the Data API acceptance tests
ruslantalpa 58b39d2
Reject a postgres_data_apis entry that sets only parent
ruslantalpa ed7fa4e
Document Data API field removal and status.url limitations
ruslantalpa 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 @@ | ||
| * Add the `postgres_data_apis` resource (Private Preview) for enabling and configuring the Data API of a Lakebase Postgres database. ([#7160](https://github.com/databricks/cli/pull/7160)) |
10 changes: 10 additions & 0 deletions
10
acceptance/bundle/deployment/bind/postgres_data_api/databricks.yml
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,10 @@ | ||
| bundle: | ||
| name: test-bundle | ||
|
|
||
| resources: | ||
| postgres_data_apis: | ||
| data_api1: | ||
| parent: projects/test-project/branches/production/databases/test-database | ||
| db_schemas: | ||
| - public | ||
| db_max_rows: 500 |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/deployment/bind/postgres_data_api/out.test.toml
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,2 @@ | ||
| Cloud = false | ||
| EnvMatrix.DMS = [""] |
94 changes: 94 additions & 0 deletions
94
acceptance/bundle/deployment/bind/postgres_data_api/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,94 @@ | ||
|
|
||
| === Enable the Data API on a database outside the bundle | ||
| === Deploy fails because the Data API is already enabled | ||
| >>> musterr [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Error: cannot create resources.postgres_data_apis.data_api1: Data API is already enabled for this database (409 ALREADY_EXISTS) | ||
|
|
||
| Endpoint: POST [DATABRICKS_URL]/api/2.0/postgres/projects/test-project/branches/production/databases/test-database/data-api | ||
| HTTP Status: 409 Conflict | ||
| API error_code: ALREADY_EXISTS | ||
| API message: Data API is already enabled for this database | ||
|
|
||
| Files: 2 uploaded, 0 deleted | ||
|
|
||
| === Bind adopts the existing Data API | ||
| >>> [CLI] bundle deployment bind data_api1 projects/test-project/branches/production/databases/test-database/data-api --auto-approve | ||
| Successfully bound postgres_data_api with an id 'projects/test-project/branches/production/databases/test-database/data-api' | ||
| Run 'bundle deploy' to deploy changes to your workspace | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test-bundle | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default | ||
| Resources: | ||
| Postgres Data APIs: | ||
| data_api1: | ||
| Name: projects/test-project/branches/production/databases/test-database/data-api | ||
|
|
||
| >>> [CLI] bundle plan | ||
| update postgres_data_apis.data_api1 | ||
|
|
||
| Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Updated postgres_data_apis.data_api1 | ||
| Files: 0 uploaded, 0 deleted | ||
| Resources: 0 created, 1 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> [CLI] postgres get-data-api projects/test-project/branches/production/databases/test-database/data-api | ||
| { | ||
| "name": "projects/test-project/branches/production/databases/test-database/data-api", | ||
| "status": { | ||
| "db_schemas": [ | ||
| "public" | ||
| ], | ||
| "db_max_rows": 500 | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged | ||
|
|
||
| === Unbind leaves the Data API enabled | ||
| >>> [CLI] bundle deployment unbind data_api1 | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test-bundle | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default | ||
| Resources: | ||
| Postgres Data APIs: | ||
| data_api1: | ||
| Name: | ||
|
|
||
| >>> [CLI] postgres get-data-api projects/test-project/branches/production/databases/test-database/data-api | ||
| { | ||
| "name": "projects/test-project/branches/production/databases/test-database/data-api" | ||
| } | ||
|
|
||
| === Bind again; destroy turns off the Data API | ||
| >>> [CLI] bundle deployment bind data_api1 projects/test-project/branches/production/databases/test-database/data-api --auto-approve | ||
| Successfully bound postgres_data_api with an id 'projects/test-project/branches/production/databases/test-database/data-api' | ||
| Run 'bundle deploy' to deploy changes to your workspace | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.postgres_data_apis.data_api1 | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default | ||
|
|
||
| Destroy: 1 deleted | ||
|
|
||
| >>> musterr [CLI] postgres get-data-api projects/test-project/branches/production/databases/test-database/data-api | ||
| Error: Data API is not enabled for this database | ||
|
|
||
| >>> [CLI] postgres get-database projects/test-project/branches/production/databases/test-database | ||
| { | ||
| "name": "projects/test-project/branches/production/databases/test-database" | ||
| } |
31 changes: 31 additions & 0 deletions
31
acceptance/bundle/deployment/bind/postgres_data_api/script
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,31 @@ | ||
| DATABASE_NAME="projects/test-project/branches/production/databases/test-database" | ||
| DATA_API_NAME="${DATABASE_NAME}/data-api" | ||
|
|
||
| title "Enable the Data API on a database outside the bundle" | ||
| $CLI postgres create-project test-project --json '{"spec": {"display_name": "Test Project", "pg_version": 16}}' &> LOG.setup | ||
| $CLI postgres create-database projects/test-project/branches/production --database-id test-database --json '{"spec": {"postgres_database": "app_db", "role": "projects/test-project/branches/production/roles/owner"}}' >> LOG.setup 2>&1 | ||
| $CLI postgres create-data-api "${DATABASE_NAME}" --json '{"spec": {"db_schemas": ["public"]}}' >> LOG.setup 2>&1 | ||
|
|
||
| title "Deploy fails because the Data API is already enabled" | ||
| trace musterr $CLI bundle deploy | ||
|
|
||
| title "Bind adopts the existing Data API" | ||
| # Bind records the config as state. The plan compares it with the spec read back | ||
| # from status, so the configured db_max_rows is applied on the next deploy. | ||
| trace $CLI bundle deployment bind data_api1 "${DATA_API_NAME}" --auto-approve | ||
| trace $CLI bundle summary | ||
| trace $CLI bundle plan | ||
| trace $CLI bundle deploy | ||
| trace $CLI postgres get-data-api "${DATA_API_NAME}" | jq '{name, status: (.status | {db_schemas, db_max_rows})}' | ||
| trace $CLI bundle plan | ||
|
|
||
| title "Unbind leaves the Data API enabled" | ||
| trace $CLI bundle deployment unbind data_api1 | ||
| trace $CLI bundle summary | ||
| trace $CLI postgres get-data-api "${DATA_API_NAME}" | jq '{name}' | ||
|
|
||
| title "Bind again; destroy turns off the Data API" | ||
| trace $CLI bundle deployment bind data_api1 "${DATA_API_NAME}" --auto-approve | ||
| trace $CLI bundle destroy --auto-approve | ||
| trace musterr $CLI postgres get-data-api "${DATA_API_NAME}" | ||
| trace $CLI postgres get-database "${DATABASE_NAME}" | jq '{name}' |
9 changes: 9 additions & 0 deletions
9
acceptance/bundle/deployment/bind/postgres_data_api/test.toml
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,9 @@ | ||
| Cloud = false | ||
|
|
||
| # Deployment history has no "postgres_data_apis." resource-key prefix yet. See dmsResourceTypes in | ||
| # libs/testserver/bundledeployments.go, which mirrors Universe. | ||
| EnvMatrixExclude.no_data_api_dms = ["DMS=true"] | ||
|
|
||
| Ignore = [ | ||
| ".databricks" | ||
| ] |
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
45 changes: 45 additions & 0 deletions
45
acceptance/bundle/invariant/configs/postgres_data_api.yml.tmpl
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,45 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| postgres_projects: | ||
| project: | ||
| project_id: test-pg-project-$UNIQUE_NAME | ||
| display_name: Test Postgres Project | ||
|
|
||
| # The Data API needs a read-write endpoint on the branch. Take over the | ||
| # "production" branch created with the project, which comes with one. | ||
| postgres_branches: | ||
| production: | ||
| parent: ${resources.postgres_projects.project.name} | ||
| branch_id: production | ||
| replace_existing: true | ||
| no_expiry: true | ||
|
|
||
| postgres_roles: | ||
| owner: | ||
| parent: ${resources.postgres_branches.production.name} | ||
| role_id: test-role-$UNIQUE_NAME | ||
| postgres_role: app_role | ||
|
|
||
| postgres_databases: | ||
| database: | ||
| parent: ${resources.postgres_branches.production.name} | ||
| database_id: test-database-$UNIQUE_NAME | ||
| postgres_database: app_db | ||
| role: ${resources.postgres_roles.owner.name} | ||
|
|
||
| postgres_data_apis: | ||
| foo: | ||
| parent: ${resources.postgres_databases.database.name} | ||
| db_schemas: | ||
| - public | ||
| db_max_rows: 1000 # CAN_REMOVE | ||
| server_cors_allowed_origins: # CAN_REMOVE | ||
| - https://app.example.com # CAN_REMOVE | ||
| jwt_cache_max_lifetime: 300s # CAN_REMOVE | ||
| openapi_mode: OPEN_API_MODE_IGNORE_PRIVILEGES # CAN_REMOVE | ||
| # Removing a bool converges like the other fields: the server keeps the | ||
| # last value and status reports it. | ||
| db_aggregates_enabled: false # CAN_REMOVE | ||
| server_timing_enabled: true # CAN_REMOVE |
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
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
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
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
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
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
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,40 @@ | ||
| resources.postgres_data_apis.*.create_time *time.Time REMOTE | ||
| resources.postgres_data_apis.*.db_aggregates_enabled bool ALL | ||
| resources.postgres_data_apis.*.db_extra_search_path []string ALL | ||
| resources.postgres_data_apis.*.db_extra_search_path[*] string ALL | ||
| resources.postgres_data_apis.*.db_max_rows int ALL | ||
| resources.postgres_data_apis.*.db_schemas []string ALL | ||
| resources.postgres_data_apis.*.db_schemas[*] string ALL | ||
| resources.postgres_data_apis.*.id string INPUT | ||
| resources.postgres_data_apis.*.jwt_cache_max_lifetime *duration.Duration ALL | ||
| resources.postgres_data_apis.*.jwt_role_claim_key string ALL | ||
| resources.postgres_data_apis.*.lifecycle resources.Lifecycle INPUT | ||
| resources.postgres_data_apis.*.lifecycle.depends_on []resources.DependsOn INPUT | ||
| resources.postgres_data_apis.*.lifecycle.depends_on[*] resources.DependsOn INPUT | ||
| resources.postgres_data_apis.*.lifecycle.depends_on[*].resource string INPUT | ||
| resources.postgres_data_apis.*.lifecycle.prevent_destroy bool INPUT | ||
| resources.postgres_data_apis.*.modified_status string INPUT | ||
| resources.postgres_data_apis.*.name string REMOTE | ||
| resources.postgres_data_apis.*.openapi_mode postgres.OpenApiMode ALL | ||
| resources.postgres_data_apis.*.parent string ALL | ||
| resources.postgres_data_apis.*.server_cors_allowed_origins []string ALL | ||
| resources.postgres_data_apis.*.server_cors_allowed_origins[*] string ALL | ||
| resources.postgres_data_apis.*.server_timing_enabled bool ALL | ||
| resources.postgres_data_apis.*.status *postgres.DataApiDataApiStatus REMOTE | ||
| resources.postgres_data_apis.*.status.available_schemas []string REMOTE | ||
| resources.postgres_data_apis.*.status.available_schemas[*] string REMOTE | ||
| resources.postgres_data_apis.*.status.db_aggregates_enabled bool REMOTE | ||
| resources.postgres_data_apis.*.status.db_extra_search_path []string REMOTE | ||
| resources.postgres_data_apis.*.status.db_extra_search_path[*] string REMOTE | ||
| resources.postgres_data_apis.*.status.db_max_rows int REMOTE | ||
| resources.postgres_data_apis.*.status.db_schemas []string REMOTE | ||
| resources.postgres_data_apis.*.status.db_schemas[*] string REMOTE | ||
| resources.postgres_data_apis.*.status.jwt_cache_max_lifetime *duration.Duration REMOTE | ||
| resources.postgres_data_apis.*.status.jwt_role_claim_key string REMOTE | ||
| resources.postgres_data_apis.*.status.openapi_mode postgres.OpenApiMode REMOTE | ||
| resources.postgres_data_apis.*.status.server_cors_allowed_origins []string REMOTE | ||
| resources.postgres_data_apis.*.status.server_cors_allowed_origins[*] string REMOTE | ||
| resources.postgres_data_apis.*.status.server_timing_enabled bool REMOTE | ||
| resources.postgres_data_apis.*.status.url string REMOTE | ||
| resources.postgres_data_apis.*.update_time *time.Time REMOTE | ||
| resources.postgres_data_apis.*.url string INPUT |
41 changes: 41 additions & 0 deletions
41
acceptance/bundle/resources/postgres_data_apis/basic/databricks.yml.tmpl
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,41 @@ | ||
| bundle: | ||
| name: deploy-pg-data-api-$UNIQUE_NAME | ||
|
|
||
| sync: | ||
| paths: [] | ||
|
|
||
| resources: | ||
| postgres_projects: | ||
| my_project: | ||
| project_id: test-pg-proj-$UNIQUE_NAME | ||
| display_name: "Test Project for Data API" | ||
| pg_version: 16 | ||
|
|
||
| # The Data API needs a read-write endpoint on the branch. Take over the | ||
| # "production" branch created with the project, which comes with one. | ||
| postgres_branches: | ||
| production: | ||
| parent: ${resources.postgres_projects.my_project.id} | ||
| branch_id: production | ||
| replace_existing: true | ||
| no_expiry: true | ||
|
|
||
| postgres_roles: | ||
| owner: | ||
| parent: ${resources.postgres_branches.production.id} | ||
| role_id: app-owner | ||
| postgres_role: app_owner | ||
|
|
||
| postgres_databases: | ||
| my_database: | ||
| parent: ${resources.postgres_branches.production.id} | ||
| database_id: my-database | ||
| postgres_database: app_db | ||
| role: ${resources.postgres_roles.owner.id} | ||
|
|
||
| postgres_data_apis: | ||
| my_data_api: | ||
| parent: ${resources.postgres_databases.my_database.name} | ||
| db_schemas: | ||
| - public | ||
| db_max_rows: 100 | ||
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.
Uh oh!
There was an error while loading. Please reload this page.