From 5794fd935df7f44e6f8ba14b84d553de7e665ab9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 04:31:49 +0000 Subject: [PATCH 01/27] chore(deps): bump github.com/andybalholm/brotli from 1.1.0 to 1.1.1 (#2756) Bumps [github.com/andybalholm/brotli](https://github.com/andybalholm/brotli) from 1.1.0 to 1.1.1. - [Commits](https://github.com/andybalholm/brotli/compare/v1.1.0...v1.1.1) --- updated-dependencies: - dependency-name: github.com/andybalholm/brotli dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 75fde9770..8e955d0cb 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.4 require ( github.com/BurntSushi/toml v1.4.0 github.com/Netflix/go-env v0.0.0-20220526054621-78278af1949d - github.com/andybalholm/brotli v1.1.0 + github.com/andybalholm/brotli v1.1.1 github.com/cenkalti/backoff/v4 v4.3.0 github.com/charmbracelet/bubbles v0.18.0 github.com/charmbracelet/bubbletea v0.25.0 diff --git a/go.sum b/go.sum index b55cc5fc9..1fe441a6e 100644 --- a/go.sum +++ b/go.sum @@ -95,8 +95,8 @@ github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pO github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw= github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= -github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= +github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= +github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= @@ -992,6 +992,8 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17 github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU= github.com/xen0n/gosmopolitan v1.2.2/go.mod h1:7XX7Mj61uLYrj0qmeN0zi7XDon9JRAEhYQqAPLVNTeg= +github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= +github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM= github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk= github.com/yeya24/promlinter v0.3.0 h1:JVDbMp08lVCP7Y6NP3qHroGAO6z2yGKQtS5JsjqtoFs= From 8e518914fb6721a8e438611c8d5b6530a7d5fc6a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 01:17:31 +0800 Subject: [PATCH 02/27] chore(deps): bump github.com/Netflix/go-env from 0.0.0-20220526054621-78278af1949d to 0.1.0 (#2755) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8e955d0cb..663659572 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.4 require ( github.com/BurntSushi/toml v1.4.0 - github.com/Netflix/go-env v0.0.0-20220526054621-78278af1949d + github.com/Netflix/go-env v0.1.0 github.com/andybalholm/brotli v1.1.1 github.com/cenkalti/backoff/v4 v4.3.0 github.com/charmbracelet/bubbles v0.18.0 diff --git a/go.sum b/go.sum index 1fe441a6e..6fb5e191b 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYr github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/Netflix/go-env v0.0.0-20220526054621-78278af1949d h1:wvStE9wLpws31NiWUx+38wny1msZ/tm+eL5xmm4Y7So= -github.com/Netflix/go-env v0.0.0-20220526054621-78278af1949d/go.mod h1:9XMFaCeRyW7fC9XJOWQ+NdAv8VLG7ys7l3x4ozEGLUQ= +github.com/Netflix/go-env v0.1.0 h1:qSMk2A4D6urE/YqOKpLeOkaATGmFmMLo56E7kNNKypk= +github.com/Netflix/go-env v0.1.0/go.mod h1:9IRTAm+pQDPMpUtMLR26JOrjHnAWz3KUbhaegqTdhfY= github.com/OpenPeeDeeP/depguard/v2 v2.2.0 h1:vDfG60vDtIuf0MEOhmLlLLSzqaRM8EMcgJPdp74zmpA= github.com/OpenPeeDeeP/depguard/v2 v2.2.0/go.mod h1:CIzddKRvLBC4Au5aYP/i3nyaWQ+ClszLIuVocRiCYFQ= github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= From 87116d59dbd9082912363a42328dcd97fde7c2a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 01:17:45 +0800 Subject: [PATCH 03/27] chore(deps): bump golang.org/x/term from 0.24.0 to 0.25.0 (#2757) --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 663659572..0cdb11ba0 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( go.opentelemetry.io/otel v1.30.0 golang.org/x/mod v0.21.0 golang.org/x/oauth2 v0.23.0 - golang.org/x/term v0.24.0 + golang.org/x/term v0.25.0 google.golang.org/grpc v1.67.1 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 @@ -337,7 +337,7 @@ require ( golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.25.0 // indirect + golang.org/x/sys v0.26.0 // indirect golang.org/x/text v0.17.0 // indirect golang.org/x/tools v0.24.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect diff --git a/go.sum b/go.sum index 6fb5e191b..9fdb5c2d2 100644 --- a/go.sum +++ b/go.sum @@ -1293,8 +1293,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1309,8 +1309,8 @@ golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= -golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 4d8e3e61d9ace427228b01bc47ed7901a6d1b917 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Thu, 10 Oct 2024 12:03:46 +0800 Subject: [PATCH 04/27] chore: update openapi client --- api/beta.yaml | 277 ++++++++++++++++++++++- pkg/api/client.gen.go | 509 +++++++++++++++++++++++++++++++++++++++--- pkg/api/types.gen.go | 152 +++++++++++-- 3 files changed, 875 insertions(+), 63 deletions(-) diff --git a/api/beta.yaml b/api/beta.yaml index cba870c1e..f4b0c08c2 100644 --- a/api/beta.yaml +++ b/api/beta.yaml @@ -340,6 +340,98 @@ paths: type: array items: $ref: '#/components/schemas/ApiKeyResponse' + tags: + - Secrets + security: + - bearer: [] + post: + operationId: createApiKey + summary: '[Alpha] Creates a new API key for the project' + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateApiKeyBody' + responses: + '201': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ApiKeyResponse' + tags: + - Secrets + security: + - bearer: [] + /v1/projects/{ref}/api-keys/{id}: + patch: + operationId: updateApiKey + summary: '[Alpha] Updates an API key for the project' + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + - name: id + required: true + in: path + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateApiKeyBody' + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ApiKeyResponse' + tags: + - Secrets + security: + - bearer: [] + delete: + operationId: deleteApiKey + summary: '[Alpha] Deletes an API key for the project' + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + - name: id + required: true + in: path + schema: + type: string + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ApiKeyResponse' '403': description: '' tags: @@ -1217,7 +1309,7 @@ paths: - bearer: [] /v1/projects/{ref}/upgrade/eligibility: get: - operationId: v1-get-postgrest-upgrade-eligibility + operationId: v1-get-postgres-upgrade-eligibility summary: '[Beta] Returns the project''s eligibility for upgrades' parameters: - name: ref @@ -1245,7 +1337,7 @@ paths: - bearer: [] /v1/projects/{ref}/upgrade/status: get: - operationId: v1-get-postgrest-upgrade-status + operationId: v1-get-postgres-upgrade-status summary: '[Beta] Gets the latest status of the project''s upgrade' parameters: - name: ref @@ -1256,6 +1348,11 @@ paths: minLength: 20 maxLength: 20 type: string + - name: tracking_id + required: false + in: query + schema: + type: string responses: '200': description: '' @@ -1479,6 +1576,8 @@ paths: application/json: schema: $ref: '#/components/schemas/PostgresConfigResponse' + '403': + description: '' '500': description: Failed to update project's Postgres config tags: @@ -2426,6 +2525,10 @@ components: type: string postgres_version: type: string + postgres_engine: + type: string + release_channel: + type: string status: enum: - ACTIVE_HEALTHY @@ -2455,6 +2558,8 @@ components: - db_port - ref - postgres_version + - postgres_engine + - release_channel - status - db_host UpdateBranchBody: @@ -2547,9 +2652,17 @@ components: version: type: string description: Database version + postgres_engine: + type: string + description: Database engine + release_channel: + type: string + description: Release channel required: - host - version + - postgres_engine + - release_channel V1ProjectResponse: type: object properties: @@ -2609,6 +2722,21 @@ components: - 8xlarge - 12xlarge - 16xlarge + ReleaseChannel: + type: string + enum: + - internal + - alpha + - beta + - ga + - withdrawn + PostgresEngine: + type: string + description: >- + Postgres engine version. If not provided, the latest version will be + used. + enum: + - '15' V1CreateProjectBody: type: object properties: @@ -2635,6 +2763,7 @@ components: type: string enum: - us-east-1 + - us-east-2 - us-west-1 - us-west-2 - ap-east-1 @@ -2645,7 +2774,9 @@ components: - eu-west-1 - eu-west-2 - eu-west-3 + - eu-north-1 - eu-central-1 + - eu-central-2 - ca-central-1 - ap-south-1 - sa-east-1 @@ -2662,6 +2793,10 @@ components: description: Template URL used to create the project from the CLI. example: >- https://github.com/supabase/supabase/tree/master/examples/slack-clone/nextjs-slack-clone + release_channel: + $ref: '#/components/schemas/ReleaseChannel' + postgres_engine: + $ref: '#/components/schemas/PostgresEngine' required: - db_pass - name @@ -2851,6 +2986,13 @@ components: - owner - updated_by - content + ApiKeySecretJWTTemplate: + type: object + properties: + role: + type: string + required: + - role ApiKeyResponse: type: object properties: @@ -2858,14 +3000,70 @@ components: type: string api_key: type: string + id: + type: string + nullable: true + type: + nullable: true + type: object + prefix: + type: string + nullable: true + description: + type: string + nullable: true + hash: + type: string + nullable: true + secret_jwt_template: + nullable: true + allOf: + - $ref: '#/components/schemas/ApiKeySecretJWTTemplate' + inserted_at: + type: string + nullable: true + updated_at: + type: string + nullable: true required: - name - api_key + CreateApiKeyBody: + type: object + properties: + type: + enum: + - publishable + - secret + type: string + description: + type: string + nullable: true + secret_jwt_template: + nullable: true + allOf: + - $ref: '#/components/schemas/ApiKeySecretJWTTemplate' + required: + - type + UpdateApiKeyBody: + type: object + properties: + description: + type: string + nullable: true + secret_jwt_template: + nullable: true + allOf: + - $ref: '#/components/schemas/ApiKeySecretJWTTemplate' CreateBranchBody: type: object properties: desired_instance_size: $ref: '#/components/schemas/DesiredInstanceSize' + release_channel: + $ref: '#/components/schemas/ReleaseChannel' + postgres_engine: + $ref: '#/components/schemas/PostgresEngine' branch_name: type: string git_branch: @@ -3221,9 +3419,12 @@ components: UpgradeDatabaseBody: type: object properties: + release_channel: + $ref: '#/components/schemas/ReleaseChannel' target_version: - type: number + type: string required: + - release_channel - target_version ProjectUpgradeInitiateResponse: type: object @@ -3236,15 +3437,20 @@ components: type: object properties: postgres_version: - type: number + $ref: '#/components/schemas/PostgresEngine' + release_channel: + $ref: '#/components/schemas/ReleaseChannel' app_version: type: string required: - postgres_version + - release_channel - app_version ProjectUpgradeEligibilityResponse: type: object properties: + current_app_version_release_channel: + $ref: '#/components/schemas/ReleaseChannel' eligible: type: boolean current_app_version: @@ -3270,6 +3476,7 @@ components: items: type: string required: + - current_app_version_release_channel - eligible - current_app_version - latest_app_version @@ -3353,6 +3560,7 @@ components: type: string enum: - us-east-1 + - us-east-2 - us-west-1 - us-west-2 - ap-east-1 @@ -3363,7 +3571,9 @@ components: - eu-west-1 - eu-west-2 - eu-west-3 + - eu-north-1 - eu-central-1 + - eu-central-2 - ca-central-1 - ap-south-1 - sa-east-1 @@ -3437,10 +3647,10 @@ components: PostgresConfigResponse: type: object properties: - statement_timeout: - type: string effective_cache_size: type: string + logical_decoding_work_mem: + type: string maintenance_work_mem: type: string max_connections: @@ -3463,16 +3673,30 @@ components: type: integer minimum: 0 maximum: 1024 + max_replication_slots: + type: integer + max_slot_wal_keep_size: + type: string max_standby_archive_delay: type: string max_standby_streaming_delay: type: string + max_wal_size: + type: string + max_wal_senders: + type: integer max_worker_processes: type: integer minimum: 0 maximum: 262143 shared_buffers: type: string + statement_timeout: + type: string + wal_keep_size: + type: string + wal_sender_timeout: + type: string work_mem: type: string session_replication_role: @@ -3484,10 +3708,10 @@ components: UpdatePostgresConfigBody: type: object properties: - statement_timeout: - type: string effective_cache_size: type: string + logical_decoding_work_mem: + type: string maintenance_work_mem: type: string max_connections: @@ -3510,18 +3734,34 @@ components: type: integer minimum: 0 maximum: 1024 + max_replication_slots: + type: integer + max_slot_wal_keep_size: + type: string max_standby_archive_delay: type: string max_standby_streaming_delay: type: string + max_wal_size: + type: string + max_wal_senders: + type: integer max_worker_processes: type: integer minimum: 0 maximum: 262143 shared_buffers: type: string + statement_timeout: + type: string + wal_keep_size: + type: string + wal_sender_timeout: + type: string work_mem: type: string + restart_database: + type: boolean session_replication_role: enum: - origin @@ -3954,6 +4194,12 @@ components: mfa_phone_verify_enabled: type: boolean nullable: true + mfa_web_authn_enroll_enabled: + type: boolean + nullable: true + mfa_web_authn_verify_enabled: + type: boolean + nullable: true mfa_phone_otp_length: type: number mfa_phone_template: @@ -3998,6 +4244,9 @@ components: saml_external_url: type: string nullable: true + saml_allow_encrypted_assertions: + type: boolean + nullable: true security_captcha_enabled: type: boolean nullable: true @@ -4232,6 +4481,8 @@ components: - mfa_totp_verify_enabled - mfa_phone_enroll_enabled - mfa_phone_verify_enabled + - mfa_web_authn_enroll_enabled + - mfa_web_authn_verify_enabled - mfa_phone_otp_length - mfa_phone_template - mfa_phone_max_frequency @@ -4247,6 +4498,7 @@ components: - refresh_token_rotation_enabled - saml_enabled - saml_external_url + - saml_allow_encrypted_assertions - security_captcha_enabled - security_captcha_provider - security_captcha_secret @@ -4658,6 +4910,10 @@ components: type: boolean mfa_totp_verify_enabled: type: boolean + mfa_web_authn_enroll_enabled: + type: boolean + mfa_web_authn_verify_enabled: + type: boolean mfa_phone_enroll_enabled: type: boolean mfa_phone_verify_enabled: @@ -5113,11 +5369,16 @@ components: type: string enum: - AI_SQL_GENERATOR_OPT_IN + allowed_release_channels: + type: array + items: + $ref: '#/components/schemas/ReleaseChannel' id: type: string name: type: string required: - opt_in_tags + - allowed_release_channels - id - name diff --git a/pkg/api/client.gen.go b/pkg/api/client.gen.go index 151b764e7..b7c450896 100644 --- a/pkg/api/client.gen.go +++ b/pkg/api/client.gen.go @@ -142,6 +142,19 @@ type ClientInterface interface { // V1GetProjectApiKeys request V1GetProjectApiKeys(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // CreateApiKeyWithBody request with any body + CreateApiKeyWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + CreateApiKey(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteApiKey request + DeleteApiKey(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateApiKeyWithBody request with any body + UpdateApiKeyWithBody(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateApiKey(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1DisablePreviewBranching request V1DisablePreviewBranching(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -351,11 +364,11 @@ type ClientInterface interface { V1UpgradePostgresVersion(ctx context.Context, ref string, body V1UpgradePostgresVersionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // V1GetPostgrestUpgradeEligibility request - V1GetPostgrestUpgradeEligibility(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1GetPostgresUpgradeEligibility request + V1GetPostgresUpgradeEligibility(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) - // V1GetPostgrestUpgradeStatus request - V1GetPostgrestUpgradeStatus(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1GetPostgresUpgradeStatus request + V1GetPostgresUpgradeStatus(ctx context.Context, ref string, params *V1GetPostgresUpgradeStatusParams, reqEditors ...RequestEditorFn) (*http.Response, error) // V1DeactivateVanitySubdomainConfig request V1DeactivateVanitySubdomainConfig(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -608,6 +621,66 @@ func (c *Client) V1GetProjectApiKeys(ctx context.Context, ref string, reqEditors return c.Client.Do(req) } +func (c *Client) CreateApiKeyWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateApiKeyRequestWithBody(c.Server, ref, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateApiKey(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateApiKeyRequest(c.Server, ref, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteApiKey(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteApiKeyRequest(c.Server, ref, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateApiKeyWithBody(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateApiKeyRequestWithBody(c.Server, ref, id, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateApiKey(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateApiKeyRequest(c.Server, ref, id, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1DisablePreviewBranching(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1DisablePreviewBranchingRequest(c.Server, ref) if err != nil { @@ -1532,8 +1605,8 @@ func (c *Client) V1UpgradePostgresVersion(ctx context.Context, ref string, body return c.Client.Do(req) } -func (c *Client) V1GetPostgrestUpgradeEligibility(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewV1GetPostgrestUpgradeEligibilityRequest(c.Server, ref) +func (c *Client) V1GetPostgresUpgradeEligibility(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1GetPostgresUpgradeEligibilityRequest(c.Server, ref) if err != nil { return nil, err } @@ -1544,8 +1617,8 @@ func (c *Client) V1GetPostgrestUpgradeEligibility(ctx context.Context, ref strin return c.Client.Do(req) } -func (c *Client) V1GetPostgrestUpgradeStatus(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewV1GetPostgrestUpgradeStatusRequest(c.Server, ref) +func (c *Client) V1GetPostgresUpgradeStatus(ctx context.Context, ref string, params *V1GetPostgresUpgradeStatusParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1GetPostgresUpgradeStatusRequest(c.Server, ref, params) if err != nil { return nil, err } @@ -2294,6 +2367,148 @@ func NewV1GetProjectApiKeysRequest(server string, ref string) (*http.Request, er return req, nil } +// NewCreateApiKeyRequest calls the generic CreateApiKey builder with application/json body +func NewCreateApiKeyRequest(server string, ref string, body CreateApiKeyJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateApiKeyRequestWithBody(server, ref, "application/json", bodyReader) +} + +// NewCreateApiKeyRequestWithBody generates requests for CreateApiKey with any type of body +func NewCreateApiKeyRequestWithBody(server string, ref string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/api-keys", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteApiKeyRequest generates requests for DeleteApiKey +func NewDeleteApiKeyRequest(server string, ref string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/api-keys/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateApiKeyRequest calls the generic UpdateApiKey builder with application/json body +func NewUpdateApiKeyRequest(server string, ref string, id string, body UpdateApiKeyJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateApiKeyRequestWithBody(server, ref, id, "application/json", bodyReader) +} + +// NewUpdateApiKeyRequestWithBody generates requests for UpdateApiKey with any type of body +func NewUpdateApiKeyRequestWithBody(server string, ref string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/api-keys/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewV1DisablePreviewBranchingRequest generates requests for V1DisablePreviewBranching func NewV1DisablePreviewBranchingRequest(server string, ref string) (*http.Request, error) { var err error @@ -4773,8 +4988,8 @@ func NewV1UpgradePostgresVersionRequestWithBody(server string, ref string, conte return req, nil } -// NewV1GetPostgrestUpgradeEligibilityRequest generates requests for V1GetPostgrestUpgradeEligibility -func NewV1GetPostgrestUpgradeEligibilityRequest(server string, ref string) (*http.Request, error) { +// NewV1GetPostgresUpgradeEligibilityRequest generates requests for V1GetPostgresUpgradeEligibility +func NewV1GetPostgresUpgradeEligibilityRequest(server string, ref string) (*http.Request, error) { var err error var pathParam0 string @@ -4807,8 +5022,8 @@ func NewV1GetPostgrestUpgradeEligibilityRequest(server string, ref string) (*htt return req, nil } -// NewV1GetPostgrestUpgradeStatusRequest generates requests for V1GetPostgrestUpgradeStatus -func NewV1GetPostgrestUpgradeStatusRequest(server string, ref string) (*http.Request, error) { +// NewV1GetPostgresUpgradeStatusRequest generates requests for V1GetPostgresUpgradeStatus +func NewV1GetPostgresUpgradeStatusRequest(server string, ref string, params *V1GetPostgresUpgradeStatusParams) (*http.Request, error) { var err error var pathParam0 string @@ -4833,6 +5048,28 @@ func NewV1GetPostgrestUpgradeStatusRequest(server string, ref string) (*http.Req return nil, err } + if params != nil { + queryValues := queryURL.Query() + + if params.TrackingId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tracking_id", runtime.ParamLocationQuery, *params.TrackingId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err @@ -5182,6 +5419,19 @@ type ClientWithResponsesInterface interface { // V1GetProjectApiKeysWithResponse request V1GetProjectApiKeysWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetProjectApiKeysResponse, error) + // CreateApiKeyWithBodyWithResponse request with any body + CreateApiKeyWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) + + CreateApiKeyWithResponse(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) + + // DeleteApiKeyWithResponse request + DeleteApiKeyWithResponse(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) + + // UpdateApiKeyWithBodyWithResponse request with any body + UpdateApiKeyWithBodyWithResponse(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) + + UpdateApiKeyWithResponse(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) + // V1DisablePreviewBranchingWithResponse request V1DisablePreviewBranchingWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1DisablePreviewBranchingResponse, error) @@ -5391,11 +5641,11 @@ type ClientWithResponsesInterface interface { V1UpgradePostgresVersionWithResponse(ctx context.Context, ref string, body V1UpgradePostgresVersionJSONRequestBody, reqEditors ...RequestEditorFn) (*V1UpgradePostgresVersionResponse, error) - // V1GetPostgrestUpgradeEligibilityWithResponse request - V1GetPostgrestUpgradeEligibilityWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgrestUpgradeEligibilityResponse, error) + // V1GetPostgresUpgradeEligibilityWithResponse request + V1GetPostgresUpgradeEligibilityWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgresUpgradeEligibilityResponse, error) - // V1GetPostgrestUpgradeStatusWithResponse request - V1GetPostgrestUpgradeStatusWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgrestUpgradeStatusResponse, error) + // V1GetPostgresUpgradeStatusWithResponse request + V1GetPostgresUpgradeStatusWithResponse(ctx context.Context, ref string, params *V1GetPostgresUpgradeStatusParams, reqEditors ...RequestEditorFn) (*V1GetPostgresUpgradeStatusResponse, error) // V1DeactivateVanitySubdomainConfigWithResponse request V1DeactivateVanitySubdomainConfigWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1DeactivateVanitySubdomainConfigResponse, error) @@ -5749,6 +5999,72 @@ func (r V1GetProjectApiKeysResponse) StatusCode() int { return 0 } +type CreateApiKeyResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *ApiKeyResponse +} + +// Status returns HTTPResponse.Status +func (r CreateApiKeyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateApiKeyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteApiKeyResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ApiKeyResponse +} + +// Status returns HTTPResponse.Status +func (r DeleteApiKeyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteApiKeyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateApiKeyResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ApiKeyResponse +} + +// Status returns HTTPResponse.Status +func (r UpdateApiKeyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateApiKeyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1DisablePreviewBranchingResponse struct { Body []byte HTTPResponse *http.Response @@ -6948,14 +7264,14 @@ func (r V1UpgradePostgresVersionResponse) StatusCode() int { return 0 } -type V1GetPostgrestUpgradeEligibilityResponse struct { +type V1GetPostgresUpgradeEligibilityResponse struct { Body []byte HTTPResponse *http.Response JSON200 *ProjectUpgradeEligibilityResponse } // Status returns HTTPResponse.Status -func (r V1GetPostgrestUpgradeEligibilityResponse) Status() string { +func (r V1GetPostgresUpgradeEligibilityResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -6963,21 +7279,21 @@ func (r V1GetPostgrestUpgradeEligibilityResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r V1GetPostgrestUpgradeEligibilityResponse) StatusCode() int { +func (r V1GetPostgresUpgradeEligibilityResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type V1GetPostgrestUpgradeStatusResponse struct { +type V1GetPostgresUpgradeStatusResponse struct { Body []byte HTTPResponse *http.Response JSON200 *DatabaseUpgradeStatusResponse } // Status returns HTTPResponse.Status -func (r V1GetPostgrestUpgradeStatusResponse) Status() string { +func (r V1GetPostgresUpgradeStatusResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -6985,7 +7301,7 @@ func (r V1GetPostgrestUpgradeStatusResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r V1GetPostgrestUpgradeStatusResponse) StatusCode() int { +func (r V1GetPostgresUpgradeStatusResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } @@ -7290,6 +7606,49 @@ func (c *ClientWithResponses) V1GetProjectApiKeysWithResponse(ctx context.Contex return ParseV1GetProjectApiKeysResponse(rsp) } +// CreateApiKeyWithBodyWithResponse request with arbitrary body returning *CreateApiKeyResponse +func (c *ClientWithResponses) CreateApiKeyWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { + rsp, err := c.CreateApiKeyWithBody(ctx, ref, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateApiKeyResponse(rsp) +} + +func (c *ClientWithResponses) CreateApiKeyWithResponse(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { + rsp, err := c.CreateApiKey(ctx, ref, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateApiKeyResponse(rsp) +} + +// DeleteApiKeyWithResponse request returning *DeleteApiKeyResponse +func (c *ClientWithResponses) DeleteApiKeyWithResponse(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) { + rsp, err := c.DeleteApiKey(ctx, ref, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteApiKeyResponse(rsp) +} + +// UpdateApiKeyWithBodyWithResponse request with arbitrary body returning *UpdateApiKeyResponse +func (c *ClientWithResponses) UpdateApiKeyWithBodyWithResponse(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { + rsp, err := c.UpdateApiKeyWithBody(ctx, ref, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateApiKeyResponse(rsp) +} + +func (c *ClientWithResponses) UpdateApiKeyWithResponse(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { + rsp, err := c.UpdateApiKey(ctx, ref, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateApiKeyResponse(rsp) +} + // V1DisablePreviewBranchingWithResponse request returning *V1DisablePreviewBranchingResponse func (c *ClientWithResponses) V1DisablePreviewBranchingWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1DisablePreviewBranchingResponse, error) { rsp, err := c.V1DisablePreviewBranching(ctx, ref, reqEditors...) @@ -7961,22 +8320,22 @@ func (c *ClientWithResponses) V1UpgradePostgresVersionWithResponse(ctx context.C return ParseV1UpgradePostgresVersionResponse(rsp) } -// V1GetPostgrestUpgradeEligibilityWithResponse request returning *V1GetPostgrestUpgradeEligibilityResponse -func (c *ClientWithResponses) V1GetPostgrestUpgradeEligibilityWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgrestUpgradeEligibilityResponse, error) { - rsp, err := c.V1GetPostgrestUpgradeEligibility(ctx, ref, reqEditors...) +// V1GetPostgresUpgradeEligibilityWithResponse request returning *V1GetPostgresUpgradeEligibilityResponse +func (c *ClientWithResponses) V1GetPostgresUpgradeEligibilityWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgresUpgradeEligibilityResponse, error) { + rsp, err := c.V1GetPostgresUpgradeEligibility(ctx, ref, reqEditors...) if err != nil { return nil, err } - return ParseV1GetPostgrestUpgradeEligibilityResponse(rsp) + return ParseV1GetPostgresUpgradeEligibilityResponse(rsp) } -// V1GetPostgrestUpgradeStatusWithResponse request returning *V1GetPostgrestUpgradeStatusResponse -func (c *ClientWithResponses) V1GetPostgrestUpgradeStatusWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgrestUpgradeStatusResponse, error) { - rsp, err := c.V1GetPostgrestUpgradeStatus(ctx, ref, reqEditors...) +// V1GetPostgresUpgradeStatusWithResponse request returning *V1GetPostgresUpgradeStatusResponse +func (c *ClientWithResponses) V1GetPostgresUpgradeStatusWithResponse(ctx context.Context, ref string, params *V1GetPostgresUpgradeStatusParams, reqEditors ...RequestEditorFn) (*V1GetPostgresUpgradeStatusResponse, error) { + rsp, err := c.V1GetPostgresUpgradeStatus(ctx, ref, params, reqEditors...) if err != nil { return nil, err } - return ParseV1GetPostgrestUpgradeStatusResponse(rsp) + return ParseV1GetPostgresUpgradeStatusResponse(rsp) } // V1DeactivateVanitySubdomainConfigWithResponse request returning *V1DeactivateVanitySubdomainConfigResponse @@ -8429,6 +8788,84 @@ func ParseV1GetProjectApiKeysResponse(rsp *http.Response) (*V1GetProjectApiKeysR return response, nil } +// ParseCreateApiKeyResponse parses an HTTP response from a CreateApiKeyWithResponse call +func ParseCreateApiKeyResponse(rsp *http.Response) (*CreateApiKeyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateApiKeyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest ApiKeyResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + } + + return response, nil +} + +// ParseDeleteApiKeyResponse parses an HTTP response from a DeleteApiKeyWithResponse call +func ParseDeleteApiKeyResponse(rsp *http.Response) (*DeleteApiKeyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteApiKeyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ApiKeyResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseUpdateApiKeyResponse parses an HTTP response from a UpdateApiKeyWithResponse call +func ParseUpdateApiKeyResponse(rsp *http.Response) (*UpdateApiKeyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateApiKeyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ApiKeyResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseV1DisablePreviewBranchingResponse parses an HTTP response from a V1DisablePreviewBranchingWithResponse call func ParseV1DisablePreviewBranchingResponse(rsp *http.Response) (*V1DisablePreviewBranchingResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -9749,15 +10186,15 @@ func ParseV1UpgradePostgresVersionResponse(rsp *http.Response) (*V1UpgradePostgr return response, nil } -// ParseV1GetPostgrestUpgradeEligibilityResponse parses an HTTP response from a V1GetPostgrestUpgradeEligibilityWithResponse call -func ParseV1GetPostgrestUpgradeEligibilityResponse(rsp *http.Response) (*V1GetPostgrestUpgradeEligibilityResponse, error) { +// ParseV1GetPostgresUpgradeEligibilityResponse parses an HTTP response from a V1GetPostgresUpgradeEligibilityWithResponse call +func ParseV1GetPostgresUpgradeEligibilityResponse(rsp *http.Response) (*V1GetPostgresUpgradeEligibilityResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &V1GetPostgrestUpgradeEligibilityResponse{ + response := &V1GetPostgresUpgradeEligibilityResponse{ Body: bodyBytes, HTTPResponse: rsp, } @@ -9775,15 +10212,15 @@ func ParseV1GetPostgrestUpgradeEligibilityResponse(rsp *http.Response) (*V1GetPo return response, nil } -// ParseV1GetPostgrestUpgradeStatusResponse parses an HTTP response from a V1GetPostgrestUpgradeStatusWithResponse call -func ParseV1GetPostgrestUpgradeStatusResponse(rsp *http.Response) (*V1GetPostgrestUpgradeStatusResponse, error) { +// ParseV1GetPostgresUpgradeStatusResponse parses an HTTP response from a V1GetPostgresUpgradeStatusWithResponse call +func ParseV1GetPostgresUpgradeStatusResponse(rsp *http.Response) (*V1GetPostgresUpgradeStatusResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &V1GetPostgrestUpgradeStatusResponse{ + response := &V1GetPostgresUpgradeStatusResponse{ Body: bodyBytes, HTTPResponse: rsp, } diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index c59dae1a5..77714f6c3 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -50,6 +50,12 @@ const ( BranchResponseStatusRUNNINGMIGRATIONS BranchResponseStatus = "RUNNING_MIGRATIONS" ) +// Defines values for CreateApiKeyBodyType. +const ( + Publishable CreateApiKeyBodyType = "publishable" + Secret CreateApiKeyBodyType = "secret" +) + // Defines values for CreateProviderBodyType. const ( Saml CreateProviderBodyType = "saml" @@ -148,6 +154,20 @@ const ( PostgresConfigResponseSessionReplicationRoleReplica PostgresConfigResponseSessionReplicationRole = "replica" ) +// Defines values for PostgresEngine. +const ( + N15 PostgresEngine = "15" +) + +// Defines values for ReleaseChannel. +const ( + Alpha ReleaseChannel = "alpha" + Beta ReleaseChannel = "beta" + Ga ReleaseChannel = "ga" + Internal ReleaseChannel = "internal" + Withdrawn ReleaseChannel = "withdrawn" +) + // Defines values for SetUpReadReplicaBodyReadReplicaRegion. const ( SetUpReadReplicaBodyReadReplicaRegionApEast1 SetUpReadReplicaBodyReadReplicaRegion = "ap-east-1" @@ -158,11 +178,14 @@ const ( SetUpReadReplicaBodyReadReplicaRegionApSoutheast2 SetUpReadReplicaBodyReadReplicaRegion = "ap-southeast-2" SetUpReadReplicaBodyReadReplicaRegionCaCentral1 SetUpReadReplicaBodyReadReplicaRegion = "ca-central-1" SetUpReadReplicaBodyReadReplicaRegionEuCentral1 SetUpReadReplicaBodyReadReplicaRegion = "eu-central-1" + SetUpReadReplicaBodyReadReplicaRegionEuCentral2 SetUpReadReplicaBodyReadReplicaRegion = "eu-central-2" + SetUpReadReplicaBodyReadReplicaRegionEuNorth1 SetUpReadReplicaBodyReadReplicaRegion = "eu-north-1" SetUpReadReplicaBodyReadReplicaRegionEuWest1 SetUpReadReplicaBodyReadReplicaRegion = "eu-west-1" SetUpReadReplicaBodyReadReplicaRegionEuWest2 SetUpReadReplicaBodyReadReplicaRegion = "eu-west-2" SetUpReadReplicaBodyReadReplicaRegionEuWest3 SetUpReadReplicaBodyReadReplicaRegion = "eu-west-3" SetUpReadReplicaBodyReadReplicaRegionSaEast1 SetUpReadReplicaBodyReadReplicaRegion = "sa-east-1" SetUpReadReplicaBodyReadReplicaRegionUsEast1 SetUpReadReplicaBodyReadReplicaRegion = "us-east-1" + SetUpReadReplicaBodyReadReplicaRegionUsEast2 SetUpReadReplicaBodyReadReplicaRegion = "us-east-2" SetUpReadReplicaBodyReadReplicaRegionUsWest1 SetUpReadReplicaBodyReadReplicaRegion = "us-west-1" SetUpReadReplicaBodyReadReplicaRegionUsWest2 SetUpReadReplicaBodyReadReplicaRegion = "us-west-2" ) @@ -277,11 +300,14 @@ const ( V1CreateProjectBodyRegionApSoutheast2 V1CreateProjectBodyRegion = "ap-southeast-2" V1CreateProjectBodyRegionCaCentral1 V1CreateProjectBodyRegion = "ca-central-1" V1CreateProjectBodyRegionEuCentral1 V1CreateProjectBodyRegion = "eu-central-1" + V1CreateProjectBodyRegionEuCentral2 V1CreateProjectBodyRegion = "eu-central-2" + V1CreateProjectBodyRegionEuNorth1 V1CreateProjectBodyRegion = "eu-north-1" V1CreateProjectBodyRegionEuWest1 V1CreateProjectBodyRegion = "eu-west-1" V1CreateProjectBodyRegionEuWest2 V1CreateProjectBodyRegion = "eu-west-2" V1CreateProjectBodyRegionEuWest3 V1CreateProjectBodyRegion = "eu-west-3" V1CreateProjectBodyRegionSaEast1 V1CreateProjectBodyRegion = "sa-east-1" V1CreateProjectBodyRegionUsEast1 V1CreateProjectBodyRegion = "us-east-1" + V1CreateProjectBodyRegionUsEast2 V1CreateProjectBodyRegion = "us-east-2" V1CreateProjectBodyRegionUsWest1 V1CreateProjectBodyRegion = "us-west-1" V1CreateProjectBodyRegionUsWest2 V1CreateProjectBodyRegion = "us-west-2" ) @@ -371,8 +397,21 @@ type ActivateVanitySubdomainResponse struct { // ApiKeyResponse defines model for ApiKeyResponse. type ApiKeyResponse struct { - ApiKey string `json:"api_key"` - Name string `json:"name"` + ApiKey string `json:"api_key"` + Description *string `json:"description"` + Hash *string `json:"hash"` + Id *string `json:"id"` + InsertedAt *string `json:"inserted_at"` + Name string `json:"name"` + Prefix *string `json:"prefix"` + SecretJwtTemplate *ApiKeySecretJWTTemplate `json:"secret_jwt_template"` + Type *map[string]interface{} `json:"type"` + UpdatedAt *string `json:"updated_at"` +} + +// ApiKeySecretJWTTemplate defines model for ApiKeySecretJWTTemplate. +type ApiKeySecretJWTTemplate struct { + Role string `json:"role"` } // AttributeMapping defines model for AttributeMapping. @@ -521,6 +560,8 @@ type AuthConfigResponse struct { MfaPhoneVerifyEnabled *bool `json:"mfa_phone_verify_enabled"` MfaTotpEnrollEnabled *bool `json:"mfa_totp_enroll_enabled"` MfaTotpVerifyEnabled *bool `json:"mfa_totp_verify_enabled"` + MfaWebAuthnEnrollEnabled *bool `json:"mfa_web_authn_enroll_enabled"` + MfaWebAuthnVerifyEnabled *bool `json:"mfa_web_authn_verify_enabled"` PasswordHibpEnabled *bool `json:"password_hibp_enabled"` PasswordMinLength *float32 `json:"password_min_length"` PasswordRequiredCharacters *string `json:"password_required_characters"` @@ -531,6 +572,7 @@ type AuthConfigResponse struct { RateLimitTokenRefresh *float32 `json:"rate_limit_token_refresh"` RateLimitVerify *float32 `json:"rate_limit_verify"` RefreshTokenRotationEnabled *bool `json:"refresh_token_rotation_enabled"` + SamlAllowEncryptedAssertions *bool `json:"saml_allow_encrypted_assertions"` SamlEnabled *bool `json:"saml_enabled"` SamlExternalUrl *string `json:"saml_external_url"` SecurityCaptchaEnabled *bool `json:"security_captcha_enabled"` @@ -598,8 +640,10 @@ type BranchDetailResponse struct { DbPort int `json:"db_port"` DbUser *string `json:"db_user,omitempty"` JwtSecret *string `json:"jwt_secret,omitempty"` + PostgresEngine string `json:"postgres_engine"` PostgresVersion string `json:"postgres_version"` Ref string `json:"ref"` + ReleaseChannel string `json:"release_channel"` Status BranchDetailResponseStatus `json:"status"` } @@ -639,13 +683,27 @@ type CfResponse struct { Success bool `json:"success"` } +// CreateApiKeyBody defines model for CreateApiKeyBody. +type CreateApiKeyBody struct { + Description *string `json:"description"` + SecretJwtTemplate *ApiKeySecretJWTTemplate `json:"secret_jwt_template"` + Type CreateApiKeyBodyType `json:"type"` +} + +// CreateApiKeyBodyType defines model for CreateApiKeyBody.Type. +type CreateApiKeyBodyType string + // CreateBranchBody defines model for CreateBranchBody. type CreateBranchBody struct { BranchName string `json:"branch_name"` DesiredInstanceSize *DesiredInstanceSize `json:"desired_instance_size,omitempty"` GitBranch *string `json:"git_branch,omitempty"` Persistent *bool `json:"persistent,omitempty"` - Region *string `json:"region,omitempty"` + + // PostgresEngine Postgres engine version. If not provided, the latest version will be used. + PostgresEngine *PostgresEngine `json:"postgres_engine,omitempty"` + Region *string `json:"region,omitempty"` + ReleaseChannel *ReleaseChannel `json:"release_channel,omitempty"` } // CreateOrganizationBodyV1 defines model for CreateOrganizationBodyV1. @@ -866,24 +924,34 @@ type PgsodiumConfigResponse struct { // PostgresConfigResponse defines model for PostgresConfigResponse. type PostgresConfigResponse struct { EffectiveCacheSize *string `json:"effective_cache_size,omitempty"` + LogicalDecodingWorkMem *string `json:"logical_decoding_work_mem,omitempty"` MaintenanceWorkMem *string `json:"maintenance_work_mem,omitempty"` MaxConnections *int `json:"max_connections,omitempty"` MaxLocksPerTransaction *int `json:"max_locks_per_transaction,omitempty"` MaxParallelMaintenanceWorkers *int `json:"max_parallel_maintenance_workers,omitempty"` MaxParallelWorkers *int `json:"max_parallel_workers,omitempty"` MaxParallelWorkersPerGather *int `json:"max_parallel_workers_per_gather,omitempty"` + MaxReplicationSlots *int `json:"max_replication_slots,omitempty"` + MaxSlotWalKeepSize *string `json:"max_slot_wal_keep_size,omitempty"` MaxStandbyArchiveDelay *string `json:"max_standby_archive_delay,omitempty"` MaxStandbyStreamingDelay *string `json:"max_standby_streaming_delay,omitempty"` + MaxWalSenders *int `json:"max_wal_senders,omitempty"` + MaxWalSize *string `json:"max_wal_size,omitempty"` MaxWorkerProcesses *int `json:"max_worker_processes,omitempty"` SessionReplicationRole *PostgresConfigResponseSessionReplicationRole `json:"session_replication_role,omitempty"` SharedBuffers *string `json:"shared_buffers,omitempty"` StatementTimeout *string `json:"statement_timeout,omitempty"` + WalKeepSize *string `json:"wal_keep_size,omitempty"` + WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` WorkMem *string `json:"work_mem,omitempty"` } // PostgresConfigResponseSessionReplicationRole defines model for PostgresConfigResponse.SessionReplicationRole. type PostgresConfigResponseSessionReplicationRole string +// PostgresEngine Postgres engine version. If not provided, the latest version will be used. +type PostgresEngine string + // PostgrestConfigWithJWTSecretResponse defines model for PostgrestConfigWithJWTSecretResponse. type PostgrestConfigWithJWTSecretResponse struct { DbExtraSearchPath string `json:"db_extra_search_path"` @@ -897,14 +965,15 @@ type PostgrestConfigWithJWTSecretResponse struct { // ProjectUpgradeEligibilityResponse defines model for ProjectUpgradeEligibilityResponse. type ProjectUpgradeEligibilityResponse struct { - CurrentAppVersion string `json:"current_app_version"` - DurationEstimateHours float32 `json:"duration_estimate_hours"` - Eligible bool `json:"eligible"` - ExtensionDependentObjects []string `json:"extension_dependent_objects"` - LatestAppVersion string `json:"latest_app_version"` - LegacyAuthCustomRoles []string `json:"legacy_auth_custom_roles"` - PotentialBreakingChanges []string `json:"potential_breaking_changes"` - TargetUpgradeVersions []ProjectVersion `json:"target_upgrade_versions"` + CurrentAppVersion string `json:"current_app_version"` + CurrentAppVersionReleaseChannel ReleaseChannel `json:"current_app_version_release_channel"` + DurationEstimateHours float32 `json:"duration_estimate_hours"` + Eligible bool `json:"eligible"` + ExtensionDependentObjects []string `json:"extension_dependent_objects"` + LatestAppVersion string `json:"latest_app_version"` + LegacyAuthCustomRoles []string `json:"legacy_auth_custom_roles"` + PotentialBreakingChanges []string `json:"potential_breaking_changes"` + TargetUpgradeVersions []ProjectVersion `json:"target_upgrade_versions"` } // ProjectUpgradeInitiateResponse defines model for ProjectUpgradeInitiateResponse. @@ -914,8 +983,11 @@ type ProjectUpgradeInitiateResponse struct { // ProjectVersion defines model for ProjectVersion. type ProjectVersion struct { - AppVersion string `json:"app_version"` - PostgresVersion float32 `json:"postgres_version"` + AppVersion string `json:"app_version"` + + // PostgresVersion Postgres engine version. If not provided, the latest version will be used. + PostgresVersion PostgresEngine `json:"postgres_version"` + ReleaseChannel ReleaseChannel `json:"release_channel"` } // Provider defines model for Provider. @@ -941,6 +1013,9 @@ type RealtimeHealthResponse struct { Healthy bool `json:"healthy"` } +// ReleaseChannel defines model for ReleaseChannel. +type ReleaseChannel string + // RemoveNetworkBanRequest defines model for RemoveNetworkBanRequest. type RemoveNetworkBanRequest struct { Ipv4Addresses []string `json:"ipv4_addresses"` @@ -1107,6 +1182,12 @@ type TypescriptResponse struct { Types string `json:"types"` } +// UpdateApiKeyBody defines model for UpdateApiKeyBody. +type UpdateApiKeyBody struct { + Description *string `json:"description"` + SecretJwtTemplate *ApiKeySecretJWTTemplate `json:"secret_jwt_template"` +} + // UpdateAuthConfigBody defines model for UpdateAuthConfigBody. type UpdateAuthConfigBody struct { ApiMaxRequestDuration *float32 `json:"api_max_request_duration,omitempty"` @@ -1223,6 +1304,8 @@ type UpdateAuthConfigBody struct { MfaPhoneVerifyEnabled *bool `json:"mfa_phone_verify_enabled,omitempty"` MfaTotpEnrollEnabled *bool `json:"mfa_totp_enroll_enabled,omitempty"` MfaTotpVerifyEnabled *bool `json:"mfa_totp_verify_enabled,omitempty"` + MfaWebAuthnEnrollEnabled *bool `json:"mfa_web_authn_enroll_enabled,omitempty"` + MfaWebAuthnVerifyEnabled *bool `json:"mfa_web_authn_verify_enabled,omitempty"` PasswordHibpEnabled *bool `json:"password_hibp_enabled,omitempty"` PasswordMinLength *float32 `json:"password_min_length,omitempty"` PasswordRequiredCharacters *UpdateAuthConfigBodyPasswordRequiredCharacters `json:"password_required_characters,omitempty"` @@ -1316,18 +1399,26 @@ type UpdatePgsodiumConfigBody struct { // UpdatePostgresConfigBody defines model for UpdatePostgresConfigBody. type UpdatePostgresConfigBody struct { EffectiveCacheSize *string `json:"effective_cache_size,omitempty"` + LogicalDecodingWorkMem *string `json:"logical_decoding_work_mem,omitempty"` MaintenanceWorkMem *string `json:"maintenance_work_mem,omitempty"` MaxConnections *int `json:"max_connections,omitempty"` MaxLocksPerTransaction *int `json:"max_locks_per_transaction,omitempty"` MaxParallelMaintenanceWorkers *int `json:"max_parallel_maintenance_workers,omitempty"` MaxParallelWorkers *int `json:"max_parallel_workers,omitempty"` MaxParallelWorkersPerGather *int `json:"max_parallel_workers_per_gather,omitempty"` + MaxReplicationSlots *int `json:"max_replication_slots,omitempty"` + MaxSlotWalKeepSize *string `json:"max_slot_wal_keep_size,omitempty"` MaxStandbyArchiveDelay *string `json:"max_standby_archive_delay,omitempty"` MaxStandbyStreamingDelay *string `json:"max_standby_streaming_delay,omitempty"` + MaxWalSenders *int `json:"max_wal_senders,omitempty"` + MaxWalSize *string `json:"max_wal_size,omitempty"` MaxWorkerProcesses *int `json:"max_worker_processes,omitempty"` + RestartDatabase *bool `json:"restart_database,omitempty"` SessionReplicationRole *UpdatePostgresConfigBodySessionReplicationRole `json:"session_replication_role,omitempty"` SharedBuffers *string `json:"shared_buffers,omitempty"` StatementTimeout *string `json:"statement_timeout,omitempty"` + WalKeepSize *string `json:"wal_keep_size,omitempty"` + WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` WorkMem *string `json:"work_mem,omitempty"` } @@ -1382,7 +1473,8 @@ type UpdateSupavisorConfigResponsePoolMode string // UpgradeDatabaseBody defines model for UpgradeDatabaseBody. type UpgradeDatabaseBody struct { - TargetVersion float32 `json:"target_version"` + ReleaseChannel ReleaseChannel `json:"release_channel"` + TargetVersion string `json:"target_version"` } // V1Backup defines model for V1Backup. @@ -1432,8 +1524,12 @@ type V1CreateProjectBody struct { // Deprecated: Plan *V1CreateProjectBodyPlan `json:"plan,omitempty"` + // PostgresEngine Postgres engine version. If not provided, the latest version will be used. + PostgresEngine *PostgresEngine `json:"postgres_engine,omitempty"` + // Region Region you want your server to reside in - Region V1CreateProjectBodyRegion `json:"region"` + Region V1CreateProjectBodyRegion `json:"region"` + ReleaseChannel *ReleaseChannel `json:"release_channel,omitempty"` // TemplateUrl Template URL used to create the project from the CLI. TemplateUrl *string `json:"template_url,omitempty"` @@ -1450,6 +1546,12 @@ type V1DatabaseResponse struct { // Host Database host Host string `json:"host"` + // PostgresEngine Database engine + PostgresEngine string `json:"postgres_engine"` + + // ReleaseChannel Release channel + ReleaseChannel string `json:"release_channel"` + // Version Database version Version string `json:"version"` } @@ -1465,10 +1567,11 @@ type V1OrganizationMemberResponse struct { // V1OrganizationSlugResponse defines model for V1OrganizationSlugResponse. type V1OrganizationSlugResponse struct { - Id string `json:"id"` - Name string `json:"name"` - OptInTags []V1OrganizationSlugResponseOptInTags `json:"opt_in_tags"` - Plan *BillingPlanId `json:"plan,omitempty"` + AllowedReleaseChannels []ReleaseChannel `json:"allowed_release_channels"` + Id string `json:"id"` + Name string `json:"name"` + OptInTags []V1OrganizationSlugResponseOptInTags `json:"opt_in_tags"` + Plan *BillingPlanId `json:"plan,omitempty"` } // V1OrganizationSlugResponseOptInTags defines model for V1OrganizationSlugResponse.OptInTags. @@ -1662,6 +1765,11 @@ type V1GenerateTypescriptTypesParams struct { IncludedSchemas *string `form:"included_schemas,omitempty" json:"included_schemas,omitempty"` } +// V1GetPostgresUpgradeStatusParams defines parameters for V1GetPostgresUpgradeStatus. +type V1GetPostgresUpgradeStatusParams struct { + TrackingId *string `form:"tracking_id,omitempty" json:"tracking_id,omitempty"` +} + // V1ListAllSnippetsParams defines parameters for V1ListAllSnippets. type V1ListAllSnippetsParams struct { ProjectRef *string `form:"project_ref,omitempty" json:"project_ref,omitempty"` @@ -1679,6 +1787,12 @@ type V1CreateAnOrganizationJSONRequestBody = CreateOrganizationBodyV1 // V1CreateAProjectJSONRequestBody defines body for V1CreateAProject for application/json ContentType. type V1CreateAProjectJSONRequestBody = V1CreateProjectBody +// CreateApiKeyJSONRequestBody defines body for CreateApiKey for application/json ContentType. +type CreateApiKeyJSONRequestBody = CreateApiKeyBody + +// UpdateApiKeyJSONRequestBody defines body for UpdateApiKey for application/json ContentType. +type UpdateApiKeyJSONRequestBody = UpdateApiKeyBody + // V1CreateABranchJSONRequestBody defines body for V1CreateABranch for application/json ContentType. type V1CreateABranchJSONRequestBody = CreateBranchBody From 3c5c827b39450c5c48f7cf9889e703e12f8d148b Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Thu, 10 Oct 2024 12:07:50 +0800 Subject: [PATCH 05/27] feat: support postgres config update without restart --- cmd/postgres.go | 9 ++++++--- internal/postgresConfig/update/update.go | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/postgres.go b/cmd/postgres.go index 784b0aca4..1c2e0e127 100644 --- a/cmd/postgres.go +++ b/cmd/postgres.go @@ -29,12 +29,13 @@ var ( Long: `Overriding the default Postgres config could result in unstable database behavior. Custom configuration also overrides the optimizations generated based on the compute add-ons in use.`, RunE: func(cmd *cobra.Command, args []string) error { - return update.Run(cmd.Context(), flags.ProjectRef, postgresConfigValues, postgresConfigUpdateReplaceMode, afero.NewOsFs()) + return update.Run(cmd.Context(), flags.ProjectRef, postgresConfigValues, postgresConfigUpdateReplaceMode, noRestart, afero.NewOsFs()) }, } postgresConfigValues []string postgresConfigUpdateReplaceMode bool + noRestart bool ) func init() { @@ -42,8 +43,10 @@ func init() { postgresCmd.AddCommand(postgresConfigGetCmd) postgresCmd.AddCommand(postgresConfigUpdateCmd) - postgresConfigUpdateCmd.Flags().StringSliceVar(&postgresConfigValues, "config", []string{}, "Config overrides specified as a 'key=value' pair") - postgresConfigUpdateCmd.Flags().BoolVar(&postgresConfigUpdateReplaceMode, "replace-existing-overrides", false, "If true, replaces all existing overrides with the ones provided. If false (default), merges existing overrides with the ones provided.") + updateFlags := postgresConfigUpdateCmd.Flags() + updateFlags.StringSliceVar(&postgresConfigValues, "config", []string{}, "Config overrides specified as a 'key=value' pair") + updateFlags.BoolVar(&postgresConfigUpdateReplaceMode, "replace-existing-overrides", false, "If true, replaces all existing overrides with the ones provided. If false (default), merges existing overrides with the ones provided.") + updateFlags.BoolVar(&noRestart, "no-restart", false, "Do not restart the database after updating config.") rootCmd.AddCommand(postgresCmd) } diff --git a/internal/postgresConfig/update/update.go b/internal/postgresConfig/update/update.go index 00a9766f8..09db6504a 100644 --- a/internal/postgresConfig/update/update.go +++ b/internal/postgresConfig/update/update.go @@ -13,7 +13,7 @@ import ( "github.com/supabase/cli/internal/utils" ) -func Run(ctx context.Context, projectRef string, values []string, replaceOverrides bool, fsys afero.Fs) error { +func Run(ctx context.Context, projectRef string, values []string, replaceOverrides, noRestart bool, fsys afero.Fs) error { // 1. Prepare config overrides newConfigOverrides := make(map[string]string) for _, config := range values { @@ -49,6 +49,9 @@ func Run(ctx context.Context, projectRef string, values []string, replaceOverrid } // 4. update config overrides and print out final result { + if noRestart { + finalOverrides["restart_database"] = false + } bts, err := json.Marshal(finalOverrides) if err != nil { return errors.Errorf("failed to serialize config overrides: %w", err) From 54c9d208e50264852a61e6f77f0fca54060229f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 04:46:05 +0000 Subject: [PATCH 06/27] chore(deps): bump github.com/danieljoos/wincred from 1.2.1 to 1.2.2 (#2759) Bumps [github.com/danieljoos/wincred](https://github.com/danieljoos/wincred) from 1.2.1 to 1.2.2. - [Release notes](https://github.com/danieljoos/wincred/releases) - [Commits](https://github.com/danieljoos/wincred/compare/v1.2.1...v1.2.2) --- updated-dependencies: - dependency-name: github.com/danieljoos/wincred dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0cdb11ba0..237f6e624 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/charmbracelet/glamour v0.7.0 github.com/charmbracelet/lipgloss v0.12.1 github.com/containers/common v0.60.4 - github.com/danieljoos/wincred v1.2.1 + github.com/danieljoos/wincred v1.2.2 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.3.1+incompatible github.com/docker/docker v27.3.1+incompatible diff --git a/go.sum b/go.sum index 9fdb5c2d2..f71d91b6e 100644 --- a/go.sum +++ b/go.sum @@ -217,8 +217,8 @@ github.com/cyphar/filepath-securejoin v0.3.1 h1:1V7cHiaW+C+39wEfpH6XlLBQo3j/PciW github.com/cyphar/filepath-securejoin v0.3.1/go.mod h1:F7i41x/9cBF7lzCrVsYs9fuzwRZm4NQsGTBdpp6mETc= github.com/daixiang0/gci v0.13.4 h1:61UGkmpoAcxHM2hhNkZEf5SzwQtWJXTSws7jaPyqwlw= github.com/daixiang0/gci v0.13.4/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= -github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs= -github.com/danieljoos/wincred v1.2.1/go.mod h1:uGaFL9fDn3OLTvzCGulzE+SzjEe5NGlh5FdCcyfPwps= +github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0= +github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= From 13923337f0c7c6d3328d25d82c5c61746bf8ac85 Mon Sep 17 00:00:00 2001 From: Julien Goux Date: Fri, 11 Oct 2024 10:15:01 +0200 Subject: [PATCH 07/27] read env in auth.additional_redirect_urls values --- pkg/config/config.go | 5 +++++ pkg/config/config_test.go | 5 +++++ pkg/config/testdata/config.toml | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 80270124c..5fbd4661f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -833,6 +833,11 @@ func (c *baseConfig) Validate(fsys fs.FS) error { if c.Auth.SiteUrl, err = maybeLoadEnv(c.Auth.SiteUrl); err != nil { return err } + for i, url := range c.Auth.AdditionalRedirectUrls { + if c.Auth.AdditionalRedirectUrls[i], err = maybeLoadEnv(url); err != nil { + return errors.Errorf("Invalid config for auth.additional_redirect_urls[%d]: %v", i, err) + } + } // Validate email config for name, tmpl := range c.Auth.Email.Template { if len(tmpl.ContentPath) > 0 { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 7d31d77ae..68077058a 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -41,10 +41,15 @@ func TestConfigParsing(t *testing.T) { t.Setenv("AZURE_SECRET", "this is cool") t.Setenv("AUTH_SEND_SMS_SECRETS", "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==") t.Setenv("SENDGRID_API_KEY", "sendgrid") + t.Setenv("AUTH_CALLBACK_URL", "http://localhost:3000/auth/callback") assert.NoError(t, config.Load("", fsys)) // Check error assert.Equal(t, "hello", config.Auth.External["azure"].ClientId) assert.Equal(t, "this is cool", config.Auth.External["azure"].Secret) + assert.Equal(t, []string{ + "https://127.0.0.1:3000", + "http://localhost:3000/auth/callback", + }, config.Auth.AdditionalRedirectUrls) }) t.Run("config file with environment variables fails when unset", func(t *testing.T) { diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index 76e070c60..0d591d979 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -94,7 +94,7 @@ enabled = true # in emails. site_url = "http://127.0.0.1:3000" # A list of *exact* URLs that auth providers are permitted to redirect to post authentication. -additional_redirect_urls = ["https://127.0.0.1:3000"] +additional_redirect_urls = ["https://127.0.0.1:3000", "env(AUTH_CALLBACK_URL)"] # How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week). jwt_expiry = 3600 # If disabled, the refresh token will never expire. From d69776ffd0fb2055fbdee146190769a625d8185c Mon Sep 17 00:00:00 2001 From: Julien Goux Date: Fri, 11 Oct 2024 10:24:15 +0200 Subject: [PATCH 08/27] fix failing test --- pkg/config/config_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 68077058a..af3ab9563 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -75,6 +75,7 @@ func TestConfigParsing(t *testing.T) { t.Setenv("AZURE_SECRET", "this is cool") t.Setenv("AUTH_SEND_SMS_SECRETS", "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==") t.Setenv("SENDGRID_API_KEY", "sendgrid") + t.Setenv("AUTH_CALLBACK_URL", "http://localhost:3000/auth/callback") assert.NoError(t, config.Load("", fsys)) // Check the default value in the config assert.Equal(t, "http://127.0.0.1:3000", config.Auth.SiteUrl) From b40723b16678b40fa0f96173e22f1fc8d4a396a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 18:35:15 +0800 Subject: [PATCH 09/27] chore(deps): bump github.com/getsentry/sentry-go from 0.28.1 to 0.29.0 (#2758) Bumps [github.com/getsentry/sentry-go](https://github.com/getsentry/sentry-go) from 0.28.1 to 0.29.0. - [Release notes](https://github.com/getsentry/sentry-go/releases) - [Changelog](https://github.com/getsentry/sentry-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-go/compare/v0.28.1...v0.29.0) --- updated-dependencies: - dependency-name: github.com/getsentry/sentry-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 237f6e624..38ae8c75b 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/docker/docker v27.3.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 - github.com/getsentry/sentry-go v0.28.1 + github.com/getsentry/sentry-go v0.29.0 github.com/gin-gonic/gin v1.10.0 github.com/go-errors/errors v1.5.1 github.com/go-git/go-git/v5 v5.12.0 diff --git a/go.sum b/go.sum index f71d91b6e..498c5f0e6 100644 --- a/go.sum +++ b/go.sum @@ -290,8 +290,8 @@ github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uq github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= -github.com/getsentry/sentry-go v0.28.1 h1:zzaSm/vHmGllRM6Tpx1492r0YDzauArdBfkJRtY6P5k= -github.com/getsentry/sentry-go v0.28.1/go.mod h1:1fQZ+7l7eeJ3wYi82q5Hg8GqAPgefRq+FP/QhafYVgg= +github.com/getsentry/sentry-go v0.29.0 h1:YtWluuCFg9OfcqnaujpY918N/AhCCwarIDWOYSBAjCA= +github.com/getsentry/sentry-go v0.29.0/go.mod h1:jhPesDAL0Q0W2+2YEuVOvdWmVtdsr1+jtBrlDEVWwLY= github.com/ghostiam/protogetter v0.3.6 h1:R7qEWaSgFCsy20yYHNIJsU9ZOb8TziSRRxuAOTVKeOk= github.com/ghostiam/protogetter v0.3.6/go.mod h1:7lpeDnEJ1ZjL/YtyoN99ljO4z0pd3H0d18/t2dPBxHw= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= From e5444940bf7177ee62488381f1749eb140aa64cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 04:49:28 +0000 Subject: [PATCH 10/27] chore(deps): bump go.opentelemetry.io/otel from 1.30.0 to 1.31.0 (#2764) Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.30.0 to 1.31.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.30.0...v1.31.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 38ae8c75b..71209c5e1 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/stripe/pg-schema-diff v0.7.0 github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 github.com/zalando/go-keyring v0.2.5 - go.opentelemetry.io/otel v1.30.0 + go.opentelemetry.io/otel v1.31.0 golang.org/x/mod v0.21.0 golang.org/x/oauth2 v0.23.0 golang.org/x/term v0.25.0 @@ -322,10 +322,10 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect - go.opentelemetry.io/otel/metric v1.30.0 // indirect + go.opentelemetry.io/otel/metric v1.31.0 // indirect go.opentelemetry.io/otel/sdk v1.28.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.30.0 // indirect + go.opentelemetry.io/otel/trace v1.31.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/automaxprocs v1.5.3 // indirect diff --git a/go.sum b/go.sum index 498c5f0e6..eef04ae19 100644 --- a/go.sum +++ b/go.sum @@ -1030,8 +1030,8 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= -go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= +go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= +go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 h1:U2guen0GhqH8o/G2un8f/aG/y++OuW6MyCo6hT9prXk= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0/go.mod h1:yeGZANgEcpdx/WK0IvvRFC+2oLiMS2u4L/0Rj2M2Qr0= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY= @@ -1040,14 +1040,14 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 h1:R3X6Z go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0/go.mod h1:QWFXnDavXWwMx2EEcZsf3yxgEKAqsxQ+Syjp+seyInw= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03ymgYhPKmeXGk5Zu+cIZOlVzd9Zv7QIiyItjFBU= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk= -go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= -go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= +go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= +go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= -go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= -go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= +go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= +go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= From 5c58ef7fac8f0a27f56baa52dbb6d1e413636255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Mon, 14 Oct 2024 14:28:53 +0900 Subject: [PATCH 11/27] fix: bump edge-runtime to 1.58.13 (#2762) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 51f7a0f99..cb4605b64 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.83.2" studioImage = "supabase/studio:20240930-16f2b8e" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.58.12" + edgeRuntimeImage = "supabase/edge-runtime:v1.58.13" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.158.1" From 67274d750375462b7849045779f9b8dbb1719d6c Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Mon, 14 Oct 2024 11:35:32 +0200 Subject: [PATCH 12/27] fix(studio): upgrade studio image to latest (#2765) chore(studio): upgrade studio image to latest Allow to deploy this bugfix for local dev: https://github.com/supabase/supabase/pull/29646 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index cb4605b64..bc675282f 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.83.2" - studioImage = "supabase/studio:20240930-16f2b8e" + studioImage = "supabase/studio:20241014-353d054" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.58.13" vectorImage = "timberio/vector:0.28.1-alpine" From 4431fb65c3a26b5d74a1bb5308a442cc58b0470d Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Mon, 14 Oct 2024 14:07:55 +0200 Subject: [PATCH 13/27] fix: Bump studio to the latest image version 20241014 (#2766) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index bc675282f..55bd94002 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.83.2" - studioImage = "supabase/studio:20241014-353d054" + studioImage = "supabase/studio:20241014-c083b3b" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.58.13" vectorImage = "timberio/vector:0.28.1-alpine" From d4ceedac577571000593392787cc99b240d646e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 05:58:48 +0000 Subject: [PATCH 14/27] chore(deps): bump github.com/getsentry/sentry-go from 0.29.0 to 0.29.1 (#2768) Bumps [github.com/getsentry/sentry-go](https://github.com/getsentry/sentry-go) from 0.29.0 to 0.29.1. - [Release notes](https://github.com/getsentry/sentry-go/releases) - [Changelog](https://github.com/getsentry/sentry-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-go/compare/v0.29.0...v0.29.1) --- updated-dependencies: - dependency-name: github.com/getsentry/sentry-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 71209c5e1..cc65595b2 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/docker/docker v27.3.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 - github.com/getsentry/sentry-go v0.29.0 + github.com/getsentry/sentry-go v0.29.1 github.com/gin-gonic/gin v1.10.0 github.com/go-errors/errors v1.5.1 github.com/go-git/go-git/v5 v5.12.0 diff --git a/go.sum b/go.sum index eef04ae19..7a1c99e73 100644 --- a/go.sum +++ b/go.sum @@ -290,8 +290,8 @@ github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uq github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= -github.com/getsentry/sentry-go v0.29.0 h1:YtWluuCFg9OfcqnaujpY918N/AhCCwarIDWOYSBAjCA= -github.com/getsentry/sentry-go v0.29.0/go.mod h1:jhPesDAL0Q0W2+2YEuVOvdWmVtdsr1+jtBrlDEVWwLY= +github.com/getsentry/sentry-go v0.29.1 h1:DyZuChN8Hz3ARxGVV8ePaNXh1dQ7d76AiB117xcREwA= +github.com/getsentry/sentry-go v0.29.1/go.mod h1:x3AtIzN01d6SiWkderzaH28Tm0lgkafpJ5Bm3li39O0= github.com/ghostiam/protogetter v0.3.6 h1:R7qEWaSgFCsy20yYHNIJsU9ZOb8TziSRRxuAOTVKeOk= github.com/ghostiam/protogetter v0.3.6/go.mod h1:7lpeDnEJ1ZjL/YtyoN99ljO4z0pd3H0d18/t2dPBxHw= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= From a64e8d0e703837d7e18aac3e8c7d024f0b14a3a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:33:48 +0800 Subject: [PATCH 15/27] chore(deps): bump github.com/slack-go/slack from 0.14.0 to 0.15.0 (#2769) Bumps [github.com/slack-go/slack](https://github.com/slack-go/slack) from 0.14.0 to 0.15.0. - [Release notes](https://github.com/slack-go/slack/releases) - [Changelog](https://github.com/slack-go/slack/blob/master/CHANGELOG.md) - [Commits](https://github.com/slack-go/slack/compare/v0.14.0...v0.15.0) --- updated-dependencies: - dependency-name: github.com/slack-go/slack dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cc65595b2..acdccd10a 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/muesli/reflow v0.3.0 github.com/oapi-codegen/runtime v1.1.1 - github.com/slack-go/slack v0.14.0 + github.com/slack-go/slack v0.15.0 github.com/spf13/afero v1.11.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 7a1c99e73..95e137d0f 100644 --- a/go.sum +++ b/go.sum @@ -900,8 +900,8 @@ github.com/sivchari/tenv v1.7.1 h1:PSpuD4bu6fSmtWMxSGWcvqUUgIn7k3yOJhOIzVWn8Ak= github.com/sivchari/tenv v1.7.1/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg= github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= -github.com/slack-go/slack v0.14.0 h1:6c0UTfbRnvRssZUsZ2qe0Iu07VAMPjRqOa6oX8ewF4k= -github.com/slack-go/slack v0.14.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= +github.com/slack-go/slack v0.15.0 h1:LE2lj2y9vqqiOf+qIIy0GvEoxgF1N5yLGZffmEZykt0= +github.com/slack-go/slack v0.15.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= github.com/sonatard/noctx v0.0.2 h1:L7Dz4De2zDQhW8S0t+KUjY0MAQJd6SgVwhzNIc4ok00= github.com/sonatard/noctx v0.0.2/go.mod h1:kzFz+CzWSjQ2OzIm46uJZoXuBpa2+0y3T36U18dWqIo= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= From fe0097e905b8ff221ed6efb0628f82a12508ceba Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 16 Oct 2024 08:31:23 +0800 Subject: [PATCH 16/27] fix: skip upserting disabled function (#2770) * chore: refactor function enabled check * fix: skip upserting disabled function --- internal/functions/deploy/deploy.go | 24 +++++------------------- internal/functions/serve/serve.go | 9 +++++---- pkg/config/config.go | 5 +++++ pkg/function/batch.go | 4 ++++ 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index fbed1313c..25ad3372a 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -16,7 +16,6 @@ import ( func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bool, importMapPath string, fsys afero.Fs) error { // Load function config and project id - var skippedFunctions []string if err := utils.LoadConfigFS(fsys); err != nil { return err } else if len(slugs) > 0 { @@ -25,12 +24,9 @@ func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bo return err } } - } else if slugs, skippedFunctions, err = GetFunctionSlugs(fsys); err != nil { + } else if slugs, err = GetFunctionSlugs(fsys); err != nil { return err } - if len(skippedFunctions) > 0 { - fmt.Fprintf(utils.GetDebugLogger(), "Skipped deploying the following functions: %s\n", strings.Join(skippedFunctions, ", ")) - } // TODO: require all functions to be deployed from config for v2 if len(slugs) == 0 { return errors.Errorf("No Functions specified or found in %s", utils.Bold(utils.FunctionsDir)) @@ -49,23 +45,19 @@ func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bo return nil } -func GetFunctionSlugs(fsys afero.Fs) (slugs []string, disabledSlugs []string, err error) { +func GetFunctionSlugs(fsys afero.Fs) (slugs []string, err error) { pattern := filepath.Join(utils.FunctionsDir, "*", "index.ts") paths, err := afero.Glob(fsys, pattern) if err != nil { - return nil, nil, errors.Errorf("failed to glob function slugs: %w", err) + return nil, errors.Errorf("failed to glob function slugs: %w", err) } for _, path := range paths { slug := filepath.Base(filepath.Dir(path)) if utils.FuncSlugPattern.MatchString(slug) { - if isFunctionEnabled(slug) { - slugs = append(slugs, slug) - } else { - disabledSlugs = append(disabledSlugs, slug) - } + slugs = append(slugs, slug) } } - return slugs, disabledSlugs, nil + return slugs, nil } func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, fsys afero.Fs) (config.FunctionConfig, error) { @@ -100,9 +92,3 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, } return functionConfig, nil } - -func isFunctionEnabled(slug string) bool { - functionConfig := utils.Config.Functions[slug] - // If the function config Enabled is not defined, or defined and set to true - return functionConfig.Enabled == nil || *functionConfig.Enabled -} diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index 316f7c4a6..15320171d 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -209,19 +209,20 @@ func parseEnvFile(envFilePath string, fsys afero.Fs) ([]string, error) { } func populatePerFunctionConfigs(cwd, importMapPath string, noVerifyJWT *bool, fsys afero.Fs) ([]string, string, error) { - slugs, skippedFunctions, err := deploy.GetFunctionSlugs(fsys) + slugs, err := deploy.GetFunctionSlugs(fsys) if err != nil { return nil, "", err } - if len(skippedFunctions) > 0 { - fmt.Fprintf(utils.GetDebugLogger(), "Skipped serving the following functions: %s\n", strings.Join(skippedFunctions, ", ")) - } functionsConfig, err := deploy.GetFunctionConfig(slugs, importMapPath, noVerifyJWT, fsys) if err != nil { return nil, "", err } binds := []string{} for slug, fc := range functionsConfig { + if !fc.IsEnabled() { + fmt.Fprintln(os.Stderr, "Skipped serving Function:", slug) + continue + } modules, err := deploy.GetBindMounts(cwd, utils.FunctionsDir, "", fc.Entrypoint, fc.ImportMap, fsys) if err != nil { return nil, "", err diff --git a/pkg/config/config.go b/pkg/config/config.go index 5fbd4661f..82b9d0a46 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -450,6 +450,11 @@ type ( } ) +func (f function) IsEnabled() bool { + // If Enabled is not defined, or defined and set to true + return f.Enabled == nil || *f.Enabled +} + func (c *baseConfig) Clone() baseConfig { copy := *c copy.Storage.Buckets = maps.Clone(c.Storage.Buckets) diff --git a/pkg/function/batch.go b/pkg/function/batch.go index 424a8a8cd..cf5a2f161 100644 --- a/pkg/function/batch.go +++ b/pkg/function/batch.go @@ -35,6 +35,10 @@ func (s *EdgeRuntimeAPI) UpsertFunctions(ctx context.Context, functionConfig con exists[f.Slug] = struct{}{} } for slug, function := range functionConfig { + if !function.IsEnabled() { + fmt.Fprintln(os.Stderr, "Skipped deploying Function:", slug) + continue + } for _, keep := range filter { if !keep(slug) { continue From c7bdbc20a96a4b8bbb924ba96a2b6eff5977b345 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 16 Oct 2024 10:47:20 +0200 Subject: [PATCH 17/27] feat(config): add api config for branching override (#2761) * feat: add remote utils for api config * chore: split api and remote api * Revert "chore: split api and remote api" This reverts commit 23173ec9830d8ae97b43d0fa12c183b1d99f7069. * chore: make api public * Revert "Revert "chore: split api and remote api"" This reverts commit 65bc6d32004a3fb25fee19a246cf9231f726e45d. * chore: handle api enable * chore: make convert whitespace resilient * feat: add some errors handling for remotes config * chore: move diff into own package * chore: add some diff tests * chore: fix golint casting lints * Update internal/utils/cast/cast.go Co-authored-by: Han Qiao * chore: use Errorf remote config error * chore: move diff and cast to pkg * chore: minor refactor * feat: implement remote config updater * chore: minor style changes * chore: refactor duplicate project ref check to getter * chore: update error message for consistency * chore: validate duplicate remote early --------- Co-authored-by: Han Qiao Co-authored-by: Qiao Han --- internal/link/link.go | 30 +++--- pkg/cast/cast.go | 25 +++++ pkg/config/api.go | 101 ++++++++++++++++++++ pkg/config/api_test.go | 143 ++++++++++++++++++++++++++++ pkg/config/config.go | 62 ++++++++---- pkg/config/updater.go | 49 ++++++++++ pkg/config/updater_test.go | 65 +++++++++++++ {internal/link => pkg/diff}/diff.go | 2 +- pkg/parser/token.go | 3 +- 9 files changed, 442 insertions(+), 38 deletions(-) create mode 100644 pkg/cast/cast.go create mode 100644 pkg/config/api.go create mode 100644 pkg/config/api_test.go create mode 100644 pkg/config/updater.go create mode 100644 pkg/config/updater_test.go rename {internal/link => pkg/diff}/diff.go (99%) diff --git a/internal/link/link.go b/internal/link/link.go index 0c2aa1de4..8a75a8d3d 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -1,7 +1,6 @@ package link import ( - "bytes" "context" "fmt" "os" @@ -9,7 +8,6 @@ import ( "strings" "sync" - "github.com/BurntSushi/toml" "github.com/go-errors/errors" "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" @@ -20,15 +18,20 @@ import ( "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/internal/utils/tenant" "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" cliConfig "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/pkg/diff" "github.com/supabase/cli/pkg/migration" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { - original := toTomlBytes(map[string]interface{}{ + original, err := cliConfig.ToTomlBytes(map[string]interface{}{ "api": utils.Config.Api, "db": utils.Config.Db, }) + if err != nil { + fmt.Fprintln(utils.GetDebugLogger(), err) + } if err := checkRemoteProjectStatus(ctx, projectRef); err != nil { return err @@ -60,28 +63,21 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func( fmt.Fprintln(os.Stdout, "Finished "+utils.Aqua("supabase link")+".") // 4. Suggest config update - updated := toTomlBytes(map[string]interface{}{ + updated, err := cliConfig.ToTomlBytes(map[string]interface{}{ "api": utils.Config.Api, "db": utils.Config.Db, }) - // if lineDiff := cmp.Diff(original, updated); len(lineDiff) > 0 { - if lineDiff := Diff(utils.ConfigPath, original, projectRef, updated); len(lineDiff) > 0 { + if err != nil { + fmt.Fprintln(utils.GetDebugLogger(), err) + } + + if lineDiff := diff.Diff(utils.ConfigPath, original, projectRef, updated); len(lineDiff) > 0 { fmt.Fprintln(os.Stderr, utils.Yellow("WARNING:"), "Local config differs from linked project. Try updating", utils.Bold(utils.ConfigPath)) fmt.Println(string(lineDiff)) } return nil } -func toTomlBytes(config any) []byte { - var buf bytes.Buffer - enc := toml.NewEncoder(&buf) - enc.Indent = "" - if err := enc.Encode(config); err != nil { - fmt.Fprintln(utils.GetDebugLogger(), "failed to marshal toml config:", err) - } - return buf.Bytes() -} - func LinkServices(ctx context.Context, projectRef, anonKey string, fsys afero.Fs) { // Ignore non-fatal errors linking services var wg sync.WaitGroup @@ -147,7 +143,7 @@ func linkPostgrestVersion(ctx context.Context, api tenant.TenantAPI, fsys afero. } func updateApiConfig(config api.PostgrestConfigWithJWTSecretResponse) { - utils.Config.Api.MaxRows = uint(config.MaxRows) + utils.Config.Api.MaxRows = cast.IntToUint(config.MaxRows) utils.Config.Api.ExtraSearchPath = readCsv(config.DbExtraSearchPath) utils.Config.Api.Schemas = readCsv(config.DbSchema) } diff --git a/pkg/cast/cast.go b/pkg/cast/cast.go new file mode 100644 index 000000000..b72cadbbf --- /dev/null +++ b/pkg/cast/cast.go @@ -0,0 +1,25 @@ +package cast + +import "math" + +// UintToInt converts a uint to an int, handling potential overflow +func UintToInt(value uint) int { + if value <= math.MaxInt { + result := int(value) + return result + } + maxInt := math.MaxInt + return maxInt +} + +// IntToUint converts an int to a uint, handling negative values +func IntToUint(value int) uint { + if value < 0 { + return 0 + } + return uint(value) +} + +func Ptr[T any](v T) *T { + return &v +} diff --git a/pkg/config/api.go b/pkg/config/api.go new file mode 100644 index 000000000..403e290e5 --- /dev/null +++ b/pkg/config/api.go @@ -0,0 +1,101 @@ +package config + +import ( + "strings" + + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/diff" +) + +type ( + api struct { + Enabled bool `toml:"enabled"` + Schemas []string `toml:"schemas"` + ExtraSearchPath []string `toml:"extra_search_path"` + MaxRows uint `toml:"max_rows"` + // Local only config + Image string `toml:"-"` + KongImage string `toml:"-"` + Port uint16 `toml:"port"` + Tls tlsKong `toml:"tls"` + // TODO: replace [auth|studio].api_url + ExternalUrl string `toml:"external_url"` + } + + tlsKong struct { + Enabled bool `toml:"enabled"` + } +) + +func (a *api) ToUpdatePostgrestConfigBody() v1API.UpdatePostgrestConfigBody { + body := v1API.UpdatePostgrestConfigBody{} + + // When the api is disabled, remote side it just set the dbSchema to an empty value + if !a.Enabled { + body.DbSchema = cast.Ptr("") + return body + } + + // Convert Schemas to a comma-separated string + if len(a.Schemas) > 0 { + schemas := strings.Join(a.Schemas, ",") + body.DbSchema = &schemas + } + + // Convert ExtraSearchPath to a comma-separated string + if len(a.ExtraSearchPath) > 0 { + extraSearchPath := strings.Join(a.ExtraSearchPath, ",") + body.DbExtraSearchPath = &extraSearchPath + } + + // Convert MaxRows to int pointer + if a.MaxRows > 0 { + body.MaxRows = cast.Ptr(cast.UintToInt(a.MaxRows)) + } + + // Note: DbPool is not present in the Api struct, so it's not set here + return body +} + +func (a *api) fromRemoteApiConfig(remoteConfig v1API.PostgrestConfigWithJWTSecretResponse) api { + result := *a + if remoteConfig.DbSchema == "" { + result.Enabled = false + return result + } + + result.Enabled = true + // Update Schemas if present in remoteConfig + schemas := strings.Split(remoteConfig.DbSchema, ",") + result.Schemas = make([]string, len(schemas)) + // TODO: use slices.Map when upgrade go version + for i, schema := range schemas { + result.Schemas[i] = strings.TrimSpace(schema) + } + + // Update ExtraSearchPath if present in remoteConfig + extraSearchPath := strings.Split(remoteConfig.DbExtraSearchPath, ",") + result.ExtraSearchPath = make([]string, len(extraSearchPath)) + for i, path := range extraSearchPath { + result.ExtraSearchPath[i] = strings.TrimSpace(path) + } + + // Update MaxRows if present in remoteConfig + result.MaxRows = cast.IntToUint(remoteConfig.MaxRows) + + return result +} + +func (a *api) DiffWithRemote(remoteConfig v1API.PostgrestConfigWithJWTSecretResponse) ([]byte, error) { + // Convert the config values into easily comparable remoteConfig values + currentValue, err := ToTomlBytes(a) + if err != nil { + return nil, err + } + remoteCompare, err := ToTomlBytes(a.fromRemoteApiConfig(remoteConfig)) + if err != nil { + return nil, err + } + return diff.Diff("remote[api]", remoteCompare, "local[api]", currentValue), nil +} diff --git a/pkg/config/api_test.go b/pkg/config/api_test.go new file mode 100644 index 000000000..d48001244 --- /dev/null +++ b/pkg/config/api_test.go @@ -0,0 +1,143 @@ +package config + +import ( + "testing" + + "github.com/stretchr/testify/assert" + v1API "github.com/supabase/cli/pkg/api" +) + +func TestApiToUpdatePostgrestConfigBody(t *testing.T) { + t.Run("converts all fields correctly", func(t *testing.T) { + api := &api{ + Enabled: true, + Schemas: []string{"public", "private"}, + ExtraSearchPath: []string{"extensions", "public"}, + MaxRows: 1000, + } + + body := api.ToUpdatePostgrestConfigBody() + + assert.Equal(t, "public,private", *body.DbSchema) + assert.Equal(t, "extensions,public", *body.DbExtraSearchPath) + assert.Equal(t, 1000, *body.MaxRows) + }) + + t.Run("handles empty fields", func(t *testing.T) { + api := &api{} + + body := api.ToUpdatePostgrestConfigBody() + + // remote api will be false by default, leading to an empty schema on api side + assert.Equal(t, "", *body.DbSchema) + }) +} + +func TestApiDiffWithRemote(t *testing.T) { + t.Run("detects differences", func(t *testing.T) { + api := &api{ + Enabled: true, + Schemas: []string{"public", "private"}, + ExtraSearchPath: []string{"extensions", "public"}, + MaxRows: 1000, + } + + remoteConfig := v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "public", + DbExtraSearchPath: "public", + MaxRows: 500, + } + + diff, err := api.DiffWithRemote(remoteConfig) + assert.NoError(t, err, string(diff)) + + assert.Contains(t, string(diff), "-schemas = [\"public\"]") + assert.Contains(t, string(diff), "+schemas = [\"public\", \"private\"]") + assert.Contains(t, string(diff), "-extra_search_path = [\"public\"]") + assert.Contains(t, string(diff), "+extra_search_path = [\"extensions\", \"public\"]") + assert.Contains(t, string(diff), "-max_rows = 500") + assert.Contains(t, string(diff), "+max_rows = 1000") + }) + + t.Run("handles no differences", func(t *testing.T) { + api := &api{ + Enabled: true, + Schemas: []string{"public"}, + ExtraSearchPath: []string{"public"}, + MaxRows: 500, + } + + remoteConfig := v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "public", + DbExtraSearchPath: "public", + MaxRows: 500, + } + + diff, err := api.DiffWithRemote(remoteConfig) + assert.NoError(t, err) + + assert.Empty(t, diff) + }) + + t.Run("handles multiple schemas and search paths with spaces", func(t *testing.T) { + api := &api{ + Enabled: true, + Schemas: []string{"public", "private"}, + ExtraSearchPath: []string{"extensions", "public"}, + MaxRows: 500, + } + + remoteConfig := v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "public, private", + DbExtraSearchPath: "extensions, public", + MaxRows: 500, + } + + diff, err := api.DiffWithRemote(remoteConfig) + assert.NoError(t, err) + + assert.Empty(t, diff) + }) + + t.Run("handles api disabled on remote side", func(t *testing.T) { + api := &api{ + Enabled: true, + Schemas: []string{"public", "private"}, + ExtraSearchPath: []string{"extensions", "public"}, + MaxRows: 500, + } + + remoteConfig := v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "", + DbExtraSearchPath: "", + MaxRows: 0, + } + + diff, err := api.DiffWithRemote(remoteConfig) + assert.NoError(t, err, string(diff)) + + assert.Contains(t, string(diff), "-enabled = false") + assert.Contains(t, string(diff), "+enabled = true") + }) + + t.Run("handles api disabled on local side", func(t *testing.T) { + api := &api{ + Enabled: false, + Schemas: []string{"public"}, + ExtraSearchPath: []string{"public"}, + MaxRows: 500, + } + + remoteConfig := v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "public", + DbExtraSearchPath: "public", + MaxRows: 500, + } + + diff, err := api.DiffWithRemote(remoteConfig) + assert.NoError(t, err, string(diff)) + + assert.Contains(t, string(diff), "-enabled = true") + assert.Contains(t, string(diff), "+enabled = false") + }) +} diff --git a/pkg/config/config.go b/pkg/config/config.go index 82b9d0a46..3bf566bb1 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -145,23 +145,6 @@ type ( Remotes map[string]baseConfig `toml:"-"` } - api struct { - Enabled bool `toml:"enabled"` - Image string `toml:"-"` - KongImage string `toml:"-"` - Port uint16 `toml:"port"` - Schemas []string `toml:"schemas"` - ExtraSearchPath []string `toml:"extra_search_path"` - MaxRows uint `toml:"max_rows"` - Tls tlsKong `toml:"tls"` - // TODO: replace [auth|studio].api_url - ExternalUrl string `toml:"external_url"` - } - - tlsKong struct { - Enabled bool `toml:"enabled"` - } - db struct { Image string `toml:"-"` Port uint16 `toml:"port"` @@ -723,6 +706,7 @@ func (c *config) Load(path string, fsys fs.FS) error { if err := c.baseConfig.Validate(fsys); err != nil { return err } + idToName := map[string]string{} c.Remotes = make(map[string]baseConfig, len(c.Overrides)) for name, remote := range c.Overrides { base := c.baseConfig.Clone() @@ -735,10 +719,18 @@ func (c *config) Load(path string, fsys fs.FS) error { if metadata, err := toml.NewDecoder(&buf).Decode(&base); err != nil { return errors.Errorf("failed to decode remote config: %w", err) } else if undecoded := metadata.Undecoded(); len(undecoded) > 0 { - fmt.Fprintf(os.Stderr, "Unknown config fields: %+v\n", undecoded) + fmt.Fprintf(os.Stderr, "WARN: unknown config fields: %+v\n", undecoded) + } + // Cross validate remote project id + if base.ProjectId == c.baseConfig.ProjectId { + fmt.Fprintf(os.Stderr, "WARN: project_id is missing for [remotes.%s]\n", name) + } else if other, exists := idToName[base.ProjectId]; exists { + return errors.Errorf("duplicate project_id for [remotes.%s] and [remotes.%s]", other, name) + } else { + idToName[base.ProjectId] = name } if err := base.Validate(fsys); err != nil { - return err + return errors.Errorf("invalid config for [remotes.%s]: %w", name, err) } c.Remotes[name] = base } @@ -1332,3 +1324,35 @@ func (a *auth) ResolveJWKS(ctx context.Context) (string, error) { return string(jwksEncoded), nil } + +// Retrieve the final base config to use taking into account the remotes override +func (c *config) GetRemoteByProjectRef(projectRef string) (baseConfig, error) { + var result []string + // Iterate over all the config.Remotes + for name, remoteConfig := range c.Remotes { + // Check if there is one matching project_id + if remoteConfig.ProjectId == projectRef { + // Check for duplicate project IDs across remotes + result = append(result, name) + } + } + // If no matching remote config is found, return the base config + if len(result) == 0 { + return c.baseConfig, errors.Errorf("no remote found for project_id: %s", projectRef) + } + remote := c.Remotes[result[0]] + if len(result) > 1 { + return remote, errors.Errorf("multiple remotes %v have the same project_id: %s", result, projectRef) + } + return remote, nil +} + +func ToTomlBytes(config any) ([]byte, error) { + var buf bytes.Buffer + enc := toml.NewEncoder(&buf) + enc.Indent = "" + if err := enc.Encode(config); err != nil { + return nil, errors.Errorf("failed to marshal toml config: %w", err) + } + return buf.Bytes(), nil +} diff --git a/pkg/config/updater.go b/pkg/config/updater.go new file mode 100644 index 000000000..467b7bb63 --- /dev/null +++ b/pkg/config/updater.go @@ -0,0 +1,49 @@ +package config + +import ( + "context" + "fmt" + "os" + + "github.com/go-errors/errors" + v1API "github.com/supabase/cli/pkg/api" +) + +type ConfigUpdater struct { + client v1API.ClientWithResponses +} + +func NewConfigUpdater(client v1API.ClientWithResponses) ConfigUpdater { + return ConfigUpdater{client: client} +} + +func (u *ConfigUpdater) UpdateRemoteConfig(ctx context.Context, remote baseConfig) error { + if err := u.UpdateApiConfig(ctx, remote.ProjectId, remote.Api); err != nil { + return err + } + // TODO: implement other service configs, ie. auth + return nil +} + +func (u *ConfigUpdater) UpdateApiConfig(ctx context.Context, projectRef string, c api) error { + apiConfig, err := u.client.V1GetPostgrestServiceConfigWithResponse(ctx, projectRef) + if err != nil { + return errors.Errorf("failed to read API config: %w", err) + } else if apiConfig.JSON200 == nil { + return errors.Errorf("unexpected status %d: %s", apiConfig.StatusCode(), string(apiConfig.Body)) + } + apiDiff, err := c.DiffWithRemote(*apiConfig.JSON200) + if err != nil { + return err + } else if len(apiDiff) == 0 { + fmt.Fprintln(os.Stderr, "Remote API config is up to date.") + return nil + } + fmt.Fprintln(os.Stderr, "Updating API service with config:", string(apiDiff)) + if resp, err := u.client.V1UpdatePostgrestServiceConfigWithResponse(ctx, projectRef, c.ToUpdatePostgrestConfigBody()); err != nil { + return errors.Errorf("failed to update API config: %w", err) + } else if resp.JSON200 == nil { + return errors.Errorf("unexpected status %d: %s", resp.StatusCode(), string(resp.Body)) + } + return nil +} diff --git a/pkg/config/updater_test.go b/pkg/config/updater_test.go new file mode 100644 index 000000000..241d612e9 --- /dev/null +++ b/pkg/config/updater_test.go @@ -0,0 +1,65 @@ +package config + +import ( + "context" + "net/http" + "testing" + + "github.com/h2non/gock" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + v1API "github.com/supabase/cli/pkg/api" +) + +func TestUpdateApi(t *testing.T) { + server := "http://localhost" + client, err := v1API.NewClientWithResponses(server) + require.NoError(t, err) + + t.Run("updates remote config", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + gock.New(server). + Get("/v1/projects/test-project/postgrest"). + Reply(http.StatusOK). + JSON(v1API.PostgrestConfigWithJWTSecretResponse{}) + gock.New(server). + Patch("/v1/projects/test-project/postgrest"). + Reply(http.StatusOK). + JSON(v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "public,graphql_public", + DbExtraSearchPath: "public,extensions", + MaxRows: 1000, + }) + // Run test + err := updater.UpdateApiConfig(context.Background(), "test-project", api{ + Enabled: true, + Schemas: []string{"public", "graphql_public"}, + ExtraSearchPath: []string{"public", "extensions"}, + MaxRows: 1000, + }) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) + + t.Run("skips update if no diff", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + gock.New(server). + Get("/v1/projects/test-project/postgrest"). + Reply(http.StatusOK). + JSON(v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "", + DbExtraSearchPath: "public,extensions", + MaxRows: 1000, + }) + // Run test + err := updater.UpdateApiConfig(context.Background(), "test-project", api{}) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) +} diff --git a/internal/link/diff.go b/pkg/diff/diff.go similarity index 99% rename from internal/link/diff.go rename to pkg/diff/diff.go index 84f2e3494..6a40b23fc 100644 --- a/internal/link/diff.go +++ b/pkg/diff/diff.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package link +package diff import ( "bytes" diff --git a/pkg/parser/token.go b/pkg/parser/token.go index 018a6f5d4..db0084342 100644 --- a/pkg/parser/token.go +++ b/pkg/parser/token.go @@ -8,6 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/viper" + "github.com/supabase/cli/pkg/cast" ) // Equal to `startBufSize` from `bufio/scan.go` @@ -83,7 +84,7 @@ func Split(sql io.Reader, transform ...func(string) string) (stats []string, err // Increase scanner capacity to support very long lines containing e.g. geodata buf := make([]byte, startBufSize) - maxbuf := int(viper.GetSizeInBytes("SCANNER_BUFFER_SIZE")) + maxbuf := cast.UintToInt(viper.GetSizeInBytes("SCANNER_BUFFER_SIZE")) if maxbuf == 0 { maxbuf = MaxScannerCapacity } From eb5a512f726338ba9f2c5129f52574dd3f4ee75b Mon Sep 17 00:00:00 2001 From: Ankesh Verma Date: Thu, 17 Oct 2024 19:13:13 +0530 Subject: [PATCH 18/27] chore(docs): correct CLI linking to /usr/bin/supabase (#2776) fix: correct CLI linking to /usr/bin/supabase --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 750bd8895..7da7ff569 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ For Bun versions below v1.0.17, you must add `supabase` as a [trusted dependency Add a symlink to the binary in `$PATH` for easier access: ```sh - ln -s "$(go env GOPATH)/cli" /usr/bin/supabase + ln -s "$(go env GOPATH)/bin/cli" /usr/bin/supabase ``` This works on other non-standard Linux distros. From 9d30b96849849613d48696419c5e8a590cc2f69b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Thu, 17 Oct 2024 22:43:46 +0900 Subject: [PATCH 19/27] fix: bump edge-runtime to 1.59.0 (#2775) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 55bd94002..90d1b821f 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.83.2" studioImage = "supabase/studio:20241014-c083b3b" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.58.13" + edgeRuntimeImage = "supabase/edge-runtime:v1.59.0" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.158.1" From adda496b91217c5fb66a45e74d235e510ecb217b Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 18 Oct 2024 02:32:51 +0800 Subject: [PATCH 20/27] fix: squash base config with mapstructure (#2777) * fix: squash base config with mapstructure * fix: move env load settings to one place * chore: remove unused string replacer --- cmd/root.go | 13 +------------ pkg/config/config.go | 37 ++++++++++++++++++++++++++++++------- pkg/config/config_test.go | 12 ++++++++++++ 3 files changed, 43 insertions(+), 19 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index f7caa54fd..d3ef3fce9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,6 @@ import ( "github.com/getsentry/sentry-go" "github.com/go-errors/errors" - "github.com/mitchellh/mapstructure" "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -223,18 +222,8 @@ func recoverAndExit() { func init() { cobra.OnInitialize(func() { - // Allow overriding config object with automatic env - // Ref: https://github.com/spf13/viper/issues/761 - envKeysMap := map[string]interface{}{} - dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ - Result: &envKeysMap, - IgnoreUntaggedFields: true, - }) - cobra.CheckErr(err) - cobra.CheckErr(dec.Decode(utils.Config)) - cobra.CheckErr(viper.MergeConfigMap(envKeysMap)) viper.SetEnvPrefix("SUPABASE") - viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_")) + viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) viper.AutomaticEnv() }) diff --git a/pkg/config/config.go b/pkg/config/config.go index 3bf566bb1..8914dcac0 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -28,6 +28,7 @@ import ( "github.com/go-errors/errors" "github.com/golang-jwt/jwt/v5" "github.com/joho/godotenv" + "github.com/mitchellh/mapstructure" "github.com/spf13/viper" "golang.org/x/mod/semver" @@ -136,13 +137,13 @@ type ( EdgeRuntime edgeRuntime `toml:"edge_runtime"` Functions FunctionConfig `toml:"functions"` Analytics analytics `toml:"analytics"` - Experimental experimental `toml:"experimental" mapstructure:"-"` + Experimental experimental `toml:"experimental"` } config struct { - baseConfig - Overrides map[string]interface{} `toml:"remotes"` - Remotes map[string]baseConfig `toml:"-"` + baseConfig `mapstructure:",squash"` + Overrides map[string]interface{} `toml:"remotes"` + Remotes map[string]baseConfig `toml:"-"` } db struct { @@ -587,6 +588,29 @@ func (c *config) Eject(w io.Writer) error { return nil } +func (c *config) loadFromEnv() error { + // Allow overriding base config object with automatic env + // Ref: https://github.com/spf13/viper/issues/761 + envKeysMap := map[string]interface{}{} + if dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ + Result: &envKeysMap, + IgnoreUntaggedFields: true, + }); err != nil { + return errors.Errorf("failed to create decoder: %w", err) + } else if err := dec.Decode(c.baseConfig); err != nil { + return errors.Errorf("failed to decode env: %w", err) + } + v := viper.New() + v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) + v.AutomaticEnv() + if err := v.MergeConfigMap(envKeysMap); err != nil { + return errors.Errorf("failed to merge config: %w", err) + } else if err := v.Unmarshal(c); err != nil { + return errors.Errorf("failed to parse env to config: %w", err) + } + return nil +} + func (c *config) Load(path string, fsys fs.FS) error { builder := NewPathBuilder(path) // Load default values @@ -614,9 +638,8 @@ func (c *config) Load(path string, fsys fs.FS) error { // Load secrets from .env file if err := loadDefaultEnv(); err != nil { return err - } - if err := viper.Unmarshal(c); err != nil { - return errors.Errorf("failed to parse env to config: %w", err) + } else if err := c.loadFromEnv(); err != nil { + return err } // Generate JWT tokens if len(c.Auth.AnonKey) == 0 { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index af3ab9563..bef3df123 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -341,3 +341,15 @@ func TestLoadSeedPaths(t *testing.T) { assert.Empty(t, config.SqlPaths) }) } + +func TestLoadEnv(t *testing.T) { + t.Setenv("AUTH_JWT_SECRET", "test-secret") + t.Setenv("DB_ROOT_KEY", "test-root-key") + config := NewConfig() + // Run test + err := config.loadFromEnv() + // Check error + assert.NoError(t, err) + assert.Equal(t, "test-secret", config.Auth.JwtSecret) + assert.Equal(t, "test-root-key", config.Db.RootKey) +} From 5f8587b154bcf54bd4404bc28d547c54a2ed2684 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Thu, 17 Oct 2024 20:52:28 +0200 Subject: [PATCH 21/27] fix(config): use SUPABASE env prefix (#2778) * fix(config): use SUPABASE env prefix * fix: tests --- pkg/config/config.go | 1 + pkg/config/config_test.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 8914dcac0..f6329f459 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -601,6 +601,7 @@ func (c *config) loadFromEnv() error { return errors.Errorf("failed to decode env: %w", err) } v := viper.New() + v.SetEnvPrefix("SUPABASE") v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) v.AutomaticEnv() if err := v.MergeConfigMap(envKeysMap); err != nil { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index bef3df123..c10669350 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -343,8 +343,8 @@ func TestLoadSeedPaths(t *testing.T) { } func TestLoadEnv(t *testing.T) { - t.Setenv("AUTH_JWT_SECRET", "test-secret") - t.Setenv("DB_ROOT_KEY", "test-root-key") + t.Setenv("SUPABASE_AUTH_JWT_SECRET", "test-secret") + t.Setenv("SUPABASE_DB_ROOT_KEY", "test-root-key") config := NewConfig() // Run test err := config.loadFromEnv() From 8d4d6db39898e53bbb3f311299a71f44c8bb6aa5 Mon Sep 17 00:00:00 2001 From: Bobbie Soedirgo Date: Fri, 18 Oct 2024 16:11:48 +0800 Subject: [PATCH 22/27] fix: pg-meta v0.84.1 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 90d1b821f..11be00252 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -9,7 +9,7 @@ const ( kongImage = "library/kong:2.8.1" inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" - pgmetaImage = "supabase/postgres-meta:v0.83.2" + pgmetaImage = "supabase/postgres-meta:v0.84.1" studioImage = "supabase/studio:20241014-c083b3b" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.59.0" From 2da3861348bba06c43d34a53bb05b813b5e860b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 04:09:44 +0000 Subject: [PATCH 23/27] chore(deps): bump github.com/jackc/pgtype from 1.14.3 to 1.14.4 (#2785) Bumps [github.com/jackc/pgtype](https://github.com/jackc/pgtype) from 1.14.3 to 1.14.4. - [Changelog](https://github.com/jackc/pgtype/blob/master/CHANGELOG.md) - [Commits](https://github.com/jackc/pgtype/compare/v1.14.3...v1.14.4) --- updated-dependencies: - dependency-name: github.com/jackc/pgtype dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index acdccd10a..846a3306c 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438 github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 github.com/jackc/pgproto3/v2 v2.3.3 - github.com/jackc/pgtype v1.14.3 + github.com/jackc/pgtype v1.14.4 github.com/jackc/pgx/v4 v4.18.3 github.com/joho/godotenv v1.5.1 github.com/matoous/go-nanoid/v2 v2.1.0 diff --git a/go.sum b/go.sum index 95e137d0f..d9153dd90 100644 --- a/go.sum +++ b/go.sum @@ -562,8 +562,8 @@ github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCM github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgtype v1.14.3 h1:h6W9cPuHsRWQFTWUZMAKMgG5jSwQI0Zurzdvlx3Plus= -github.com/jackc/pgtype v1.14.3/go.mod h1:aKeozOde08iifGosdJpz9MBZonJOUJxqNpPBcMJTlVA= +github.com/jackc/pgtype v1.14.4 h1:fKuNiCumbKTAIxQwXfB/nsrnkEI6bPJrrSiMKgbJ2j8= +github.com/jackc/pgtype v1.14.4/go.mod h1:aKeozOde08iifGosdJpz9MBZonJOUJxqNpPBcMJTlVA= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= From ce904a1e2ecc145855d385fe3346108480b49fed Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 22 Oct 2024 00:02:12 +0800 Subject: [PATCH 24/27] fix: empty array is valid api config (#2788) * fix: empty array is valid api config * chore: revert weird api schema update * Update api.go --- pkg/config/api.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/config/api.go b/pkg/config/api.go index 403e290e5..51f516506 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -44,10 +44,7 @@ func (a *api) ToUpdatePostgrestConfigBody() v1API.UpdatePostgrestConfigBody { } // Convert ExtraSearchPath to a comma-separated string - if len(a.ExtraSearchPath) > 0 { - extraSearchPath := strings.Join(a.ExtraSearchPath, ",") - body.DbExtraSearchPath = &extraSearchPath - } + body.DbExtraSearchPath = cast.Ptr(strings.Join(a.ExtraSearchPath, ",")) // Convert MaxRows to int pointer if a.MaxRows > 0 { From 68e3663ccb5ee7712d4f282f042e527607d95580 Mon Sep 17 00:00:00 2001 From: Bobbie Soedirgo <31685197+soedirgo@users.noreply.github.com> Date: Tue, 22 Oct 2024 00:03:45 +0800 Subject: [PATCH 25/27] fix: pg-meta v0.84.2 (#2783) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 11be00252..0b2edfcf3 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -9,7 +9,7 @@ const ( kongImage = "library/kong:2.8.1" inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" - pgmetaImage = "supabase/postgres-meta:v0.84.1" + pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241014-c083b3b" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.59.0" From 47b7e9a8d877b0ac96f9ce00d348f4b495af11da Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Mon, 21 Oct 2024 16:07:36 +0000 Subject: [PATCH 26/27] fix: prune volumes without all flag for pre-Docker v1.42 (#2781) fix: prune volumes without all for pre-Docker 1.42 Before Docker API version 1.42, the `all` flag in Docker.VolumePrune` is not required. Podman prints an error like the following when the `all` flag is passed ([Podman's only compatible with Docker API v1.41][1]): ``` failed to parse filters for all=true&label=com.supabase.cli.project%3Dtest: "all" is an invalid volume filter ``` [1]: https://github.com/containers/podman/blob/290d94d3c00857dd582ffbee6bd0677a0904c783/version/version.go#L46 Fixes: bec537e98d0c2491442d44eb04b5d0407f88406c Fixes: https://github.com/supabase/cli/issues/2348#issuecomment-2149936472 --- internal/stop/stop_test.go | 19 +++++++++++++++++++ internal/testing/apitest/docker.go | 8 ++++++++ internal/utils/docker.go | 9 ++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/internal/stop/stop_test.go b/internal/stop/stop_test.go index da571330b..b607d87d7 100644 --- a/internal/stop/stop_test.go +++ b/internal/stop/stop_test.go @@ -13,6 +13,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/volume" + "github.com/docker/docker/client" "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" @@ -206,6 +207,24 @@ func TestStopServices(t *testing.T) { assert.Empty(t, apitest.ListUnmatchedRequests()) }) + t.Run("skips all filter when removing data volumes with Docker version pre-v1.42", func(t *testing.T) { + utils.DbId = "test-db" + utils.ConfigId = "test-config" + utils.StorageId = "test-storage" + utils.EdgeRuntimeId = "test-functions" + utils.InbucketId = "test-inbucket" + // Setup mock docker + require.NoError(t, apitest.MockDocker(utils.Docker)) + require.NoError(t, client.WithVersion("1.41")(utils.Docker)) + defer gock.OffAll() + apitest.MockDockerStop(utils.Docker) + // Run test + err := stop(context.Background(), false, io.Discard, utils.Config.ProjectId) + // Check error + assert.NoError(t, err) + assert.Empty(t, apitest.ListUnmatchedRequests()) + }) + t.Run("throws error on prune failure", func(t *testing.T) { // Setup mock docker require.NoError(t, apitest.MockDocker(utils.Docker)) diff --git a/internal/testing/apitest/docker.go b/internal/testing/apitest/docker.go index 21a4d7dd2..556756dfd 100644 --- a/internal/testing/apitest/docker.go +++ b/internal/testing/apitest/docker.go @@ -9,9 +9,11 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" "github.com/docker/docker/pkg/stdcopy" + "github.com/go-errors/errors" "github.com/h2non/gock" ) @@ -64,6 +66,12 @@ func MockDockerStop(docker *client.Client) { Post("/v" + docker.ClientVersion() + "/containers/prune"). Reply(http.StatusOK). JSON(container.PruneReport{}) + if !versions.GreaterThanOrEqualTo(docker.ClientVersion(), "1.42") { + gock.New(docker.DaemonHost()). + Post("/v"+docker.ClientVersion()+"/volumes/prune"). + MatchParam("filters", `"all":{"true":true}`). + ReplyError(errors.New(`failed to parse filters for all=true&label=com.supabase.cli.project%3Dtest: "all" is an invalid volume filter`)) + } gock.New(docker.DaemonHost()). Post("/v" + docker.ClientVersion() + "/volumes/prune"). Reply(http.StatusOK). diff --git a/internal/utils/docker.go b/internal/utils/docker.go index 6264c4056..84911d07f 100644 --- a/internal/utils/docker.go +++ b/internal/utils/docker.go @@ -25,6 +25,7 @@ import ( "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" "github.com/docker/docker/errdefs" @@ -125,10 +126,12 @@ func DockerRemoveAll(ctx context.Context, w io.Writer, projectId string) error { } // Remove named volumes if NoBackupVolume { - // Since docker engine 25.0.3, all flag is required to include named volumes. - // https://github.com/docker/cli/blob/master/cli/command/volume/prune.go#L76 vargs := args.Clone() - vargs.Add("all", "true") + if versions.GreaterThanOrEqualTo(Docker.ClientVersion(), "1.42") { + // Since docker engine 25.0.3, all flag is required to include named volumes. + // https://github.com/docker/cli/blob/master/cli/command/volume/prune.go#L76 + vargs.Add("all", "true") + } if report, err := Docker.VolumesPrune(ctx, vargs); err != nil { return errors.Errorf("failed to prune volumes: %w", err) } else if viper.GetBool("DEBUG") { From 1a1e908dd9a89a2887a26250c70726332256fafa Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 22 Oct 2024 00:27:42 +0800 Subject: [PATCH 27/27] fix: drop user created publications during reset (#2789) Co-authored-by: billysutomo --- pkg/migration/queries/drop.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/migration/queries/drop.sql b/pkg/migration/queries/drop.sql index 368ee7228..14d1803e2 100644 --- a/pkg/migration/queries/drop.sql +++ b/pkg/migration/queries/drop.sql @@ -74,4 +74,14 @@ begin loop execute format('drop policy if exists %I on %I.%I cascade', rec.policyname, rec.schemaname, rec.tablename); end loop; + + -- publications + for rec in + select * + from pg_publication p + where + p.pubname != 'supabase_realtime' + loop + execute format('drop publication if exists %I', rec.pubname); + end loop; end $$;