From 53c6f63acbc1669a423fba0ae9f1a826d0de9389 Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 18 Nov 2025 01:04:10 +0800 Subject: [PATCH 1/4] chore: release binaries --- .github/workflows/release-beta.yml | 79 ++++++++++++- .github/workflows/tag-npm.yml | 31 ++++- bin/supabase.js | 62 ++++++++++ npm/darwin-amd64/package.json | 14 +++ npm/darwin-arm64/package.json | 14 +++ npm/linux-amd64/package.json | 17 +++ npm/linux-arm64/package.json | 17 +++ npm/windows-amd64/package.json | 14 +++ npm/windows-arm64/package.json | 14 +++ package.json | 19 ++- scripts/bin.js | 61 ++++++++++ scripts/postinstall.js | 180 ----------------------------- 12 files changed, 323 insertions(+), 199 deletions(-) create mode 100644 bin/supabase.js create mode 100644 npm/darwin-amd64/package.json create mode 100644 npm/darwin-arm64/package.json create mode 100644 npm/linux-amd64/package.json create mode 100644 npm/linux-arm64/package.json create mode 100644 npm/windows-amd64/package.json create mode 100644 npm/windows-arm64/package.json create mode 100644 scripts/bin.js delete mode 100755 scripts/postinstall.js diff --git a/.github/workflows/release-beta.yml b/.github/workflows/release-beta.yml index 6181b2c96..9760eb9db 100644 --- a/.github/workflows/release-beta.yml +++ b/.github/workflows/release-beta.yml @@ -74,20 +74,89 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GH_PAT }} + publish-binaries: + name: Publish ${{ matrix.platform }} + needs: + - release + - goreleaser + if: needs.release.outputs.new-release-published == 'true' + runs-on: ubuntu-latest + strategy: + matrix: + include: + - platform: darwin-amd64 + os: darwin + arch: amd64 + - platform: darwin-arm64 + os: darwin + arch: arm64 + - platform: linux-amd64 + os: linux + arch: amd64 + - platform: linux-arm64 + os: linux + arch: arm64 + - platform: windows-amd64 + os: windows + arch: amd64 + ext: .exe + - platform: windows-arm64 + os: windows + arch: arm64 + ext: .exe + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-node@v6 + with: + node-version: '16.x' + registry-url: 'https://registry.npmjs.org' + - name: Download binary from release + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release download "v${{ needs.release.outputs.new-release-version }}" \ + --pattern "supabase_${{ matrix.os }}_${{ matrix.arch }}.tar.gz" \ + --repo ${{ github.repository }} + tar -xzf supabase_${{ matrix.os }}_${{ matrix.arch }}.tar.gz supabase${{ matrix.ext || '' }} + mv supabase${{ matrix.ext || '' }} npm/${{ matrix.platform }}/ + chmod +x npm/${{ matrix.platform }}/supabase${{ matrix.ext || '' }} + rm supabase_${{ matrix.os }}_${{ matrix.arch }}.tar.gz + - name: Update package version + working-directory: npm/${{ matrix.platform }} + run: npm version ${{ needs.release.outputs.new-release-version }} --no-git-tag-version + - name: Publish to NPM + working-directory: npm/${{ matrix.platform }} + run: npm publish --tag ${{ needs.release.outputs.new-release-channel }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + publish: - name: Publish NPM + name: Publish main package needs: - release - goreleaser + - publish-binaries if: needs.release.outputs.new-release-published == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v6 with: - node-version: "16.x" - registry-url: "https://registry.npmjs.org" - - run: npm --git-tag-version=false version ${{ needs.release.outputs.new-release-version }} - - run: npm publish --tag ${{ needs.release.outputs.new-release-channel }} + node-version: '16.x' + registry-url: 'https://registry.npmjs.org' + - name: Update package versions + run: | + npm version ${{ needs.release.outputs.new-release-version }} --no-git-tag-version + node -e " + const fs = require('fs'); + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); + const version = '${{ needs.release.outputs.new-release-version }}'; + for (const dep in pkg.optionalDependencies) { + pkg.optionalDependencies[dep] = version; + } + fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); + " + - name: Publish to NPM + run: npm publish --tag ${{ needs.release.outputs.new-release-channel }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/tag-npm.yml b/.github/workflows/tag-npm.yml index ac4a9ed1f..7ba7972e4 100644 --- a/.github/workflows/tag-npm.yml +++ b/.github/workflows/tag-npm.yml @@ -9,7 +9,7 @@ on: workflow_dispatch: inputs: release: - description: "v1.0.0" + description: 'v1.0.0' required: true type: string @@ -17,15 +17,38 @@ permissions: contents: read jobs: + tag-binaries: + name: Tag ${{ matrix.platform }} + runs-on: ubuntu-latest + strategy: + matrix: + platform: + - darwin-amd64 + - darwin-arm64 + - linux-amd64 + - linux-arm64 + - windows-amd64 + - windows-arm64 + steps: + - uses: actions/setup-node@v6 + with: + node-version: '16.x' + registry-url: 'https://registry.npmjs.org' + - run: npm dist-tag add "supabase-${{ matrix.platform }}@${RELEASE_TAG#v}" latest + env: + RELEASE_TAG: ${{ inputs.release }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + tag: - name: Move latest tag + name: Tag main package + needs: tag-binaries runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v6 with: - node-version: "16.x" - registry-url: "https://registry.npmjs.org" + node-version: '16.x' + registry-url: 'https://registry.npmjs.org' - run: npm dist-tag add "supabase@${RELEASE_TAG#v}" latest env: RELEASE_TAG: ${{ inputs.release }} diff --git a/bin/supabase.js b/bin/supabase.js new file mode 100644 index 000000000..d680cf7bb --- /dev/null +++ b/bin/supabase.js @@ -0,0 +1,62 @@ +#!/usr/bin/env node + +/** + * Wrapper script that delegates to the platform-specific binary. + * The actual binary is provided by one of the optional dependencies: + * - supabase-darwin-amd64 + * - supabase-darwin-arm64 + * - supabase-linux-amd64 + * - supabase-linux-arm64 + * - supabase-windows-amd64 + * - supabase-windows-arm64 + */ + +import { spawnSync } from "child_process"; +import { dirname, join } from "path"; +import { fileURLToPath } from "url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +// Mapping from Node's process.arch to package names +const ARCH_MAPPING = { + x64: "amd64", + arm64: "arm64", +}; + +// Mapping from Node's process.platform to package names +const PLATFORM_MAPPING = { + darwin: "darwin", + linux: "linux", + win32: "windows", +}; + +const arch = ARCH_MAPPING[process.arch]; +const platform = PLATFORM_MAPPING[process.platform]; + +if (!arch || !platform) { + console.error(`Unsupported platform: ${process.platform} ${process.arch}`); + process.exit(1); +} + +// Construct the package name +const packageName = `supabase-${platform}-${arch}`; + +// Construct the path to the binary +// The binary is in node_modules/{packageName}/bin/supabase[.exe] +const binaryName = platform === "windows" ? "supabase.exe" : "supabase"; +const binaryPath = join( + __dirname, + "..", + "node_modules", + packageName, + "bin", + binaryName, +); + +// Run the binary with all arguments +const result = spawnSync(binaryPath, process.argv.slice(2), { + stdio: "inherit", +}); + +// Exit with the same code as the binary +process.exit(result.status ?? 1); diff --git a/npm/darwin-amd64/package.json b/npm/darwin-amd64/package.json new file mode 100644 index 000000000..335a2f8b5 --- /dev/null +++ b/npm/darwin-amd64/package.json @@ -0,0 +1,14 @@ +{ + "name": "supabase-darwin-amd64", + "version": "0.0.0-automated", + "license": "MIT", + "os": [ + "darwin" + ], + "cpu": [ + "x64" + ], + "files": [ + "supabase" + ] +} \ No newline at end of file diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json new file mode 100644 index 000000000..4d3751800 --- /dev/null +++ b/npm/darwin-arm64/package.json @@ -0,0 +1,14 @@ +{ + "name": "supabase-darwin-arm64", + "version": "0.0.0-automated", + "license": "MIT", + "os": [ + "darwin" + ], + "cpu": [ + "arm64" + ], + "files": [ + "supabase" + ] +} \ No newline at end of file diff --git a/npm/linux-amd64/package.json b/npm/linux-amd64/package.json new file mode 100644 index 000000000..f3d1f19bb --- /dev/null +++ b/npm/linux-amd64/package.json @@ -0,0 +1,17 @@ +{ + "name": "supabase-linux-amd64", + "version": "0.0.0-automated", + "license": "MIT", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "files": [ + "supabase" + ] +} \ No newline at end of file diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json new file mode 100644 index 000000000..20b7021e5 --- /dev/null +++ b/npm/linux-arm64/package.json @@ -0,0 +1,17 @@ +{ + "name": "supabase-linux-arm64", + "version": "0.0.0-automated", + "license": "MIT", + "os": [ + "linux" + ], + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "files": [ + "supabase" + ] +} \ No newline at end of file diff --git a/npm/windows-amd64/package.json b/npm/windows-amd64/package.json new file mode 100644 index 000000000..5a1718ff4 --- /dev/null +++ b/npm/windows-amd64/package.json @@ -0,0 +1,14 @@ +{ + "name": "supabase-windows-amd64", + "version": "0.0.0-automated", + "license": "MIT", + "os": [ + "win32" + ], + "cpu": [ + "x64" + ], + "files": [ + "supabase.exe" + ] +} \ No newline at end of file diff --git a/npm/windows-arm64/package.json b/npm/windows-arm64/package.json new file mode 100644 index 000000000..c5faa474a --- /dev/null +++ b/npm/windows-arm64/package.json @@ -0,0 +1,14 @@ +{ + "name": "supabase-windows-arm64", + "version": "0.0.0-automated", + "license": "MIT", + "os": [ + "win32" + ], + "cpu": [ + "arm64" + ], + "files": [ + "supabase.exe" + ] +} \ No newline at end of file diff --git a/package.json b/package.json index 27f3470fd..024f69d5e 100644 --- a/package.json +++ b/package.json @@ -14,17 +14,16 @@ "files": [ "scripts" ], - "scripts": { - "postinstall": "node scripts/postinstall.js" - }, "bin": { - "supabase": "bin/supabase" + "supabase": "scripts/bin.js" }, - "dependencies": { - "bin-links": "^6.0.0", - "https-proxy-agent": "^7.0.2", - "node-fetch": "^3.3.2", - "tar": "7.5.2" + "optionalDependencies": { + "supabase-darwin-amd64": "0.0.0-automated", + "supabase-darwin-arm64": "0.0.0-automated", + "supabase-linux-amd64": "0.0.0-automated", + "supabase-linux-arm64": "0.0.0-automated", + "supabase-windows-amd64": "0.0.0-automated", + "supabase-windows-arm64": "0.0.0-automated" }, "release": { "branches": [ @@ -42,4 +41,4 @@ "@semantic-release/git" ] } -} +} \ No newline at end of file diff --git a/scripts/bin.js b/scripts/bin.js new file mode 100644 index 000000000..f5b77f224 --- /dev/null +++ b/scripts/bin.js @@ -0,0 +1,61 @@ +#!/usr/bin/env node + +/** + * Wrapper script that delegates to the platform-specific binary. + * The actual binary is provided by one of the optional dependencies: + * - supabase-darwin-amd64 + * - supabase-darwin-arm64 + * - supabase-linux-amd64 + * - supabase-linux-arm64 + * - supabase-windows-amd64 + * - supabase-windows-arm64 + */ + +import { spawnSync } from "child_process"; +import { dirname, join } from "path"; +import { fileURLToPath } from "url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +// Mapping from Node's process.arch to package names +const ARCH_MAPPING = { + x64: "amd64", + arm64: "arm64", +}; + +// Mapping from Node's process.platform to package names +const PLATFORM_MAPPING = { + darwin: "darwin", + linux: "linux", + win32: "windows", +}; + +const arch = ARCH_MAPPING[process.arch]; +const platform = PLATFORM_MAPPING[process.platform]; + +if (!arch || !platform) { + console.error(`Unsupported platform: ${process.platform} ${process.arch}`); + process.exit(1); +} + +// Construct the package name +const packageName = `supabase-${platform}-${arch}`; + +// Construct the path to the binary +// The binary is in node_modules/{packageName}/supabase[.exe] +const binaryName = platform === "windows" ? "supabase.exe" : "supabase"; +const binaryPath = join( + __dirname, + "..", + "node_modules", + packageName, + binaryName, +); + +// Run the binary with all arguments +const result = spawnSync(binaryPath, process.argv.slice(2), { + stdio: "inherit", +}); + +// Exit with the same code as the binary +process.exit(result.status ?? 1); diff --git a/scripts/postinstall.js b/scripts/postinstall.js deleted file mode 100755 index 517617ffb..000000000 --- a/scripts/postinstall.js +++ /dev/null @@ -1,180 +0,0 @@ -#!/usr/bin/env node - -// Ref 1: https://github.com/sanathkr/go-npm -// Ref 2: https://medium.com/xendit-engineering/how-we-repurposed-npm-to-publish-and-distribute-our-go-binaries-for-internal-cli-23981b80911b -"use strict"; - -import binLinks from "bin-links"; -import { createHash } from "crypto"; -import fs from "fs"; -import fetch from "node-fetch"; -import { Agent } from "https"; -import { HttpsProxyAgent } from "https-proxy-agent"; -import path from "path"; -import { extract } from "tar"; -import zlib from "zlib"; - -// Mapping from Node's `process.arch` to Golang's `$GOARCH` -const ARCH_MAPPING = { - x64: "amd64", - arm64: "arm64", -}; - -// Mapping between Node's `process.platform` to Golang's -const PLATFORM_MAPPING = { - darwin: "darwin", - linux: "linux", - win32: "windows", -}; - -const arch = ARCH_MAPPING[process.arch]; -const platform = PLATFORM_MAPPING[process.platform]; - -// TODO: import pkg from "../package.json" assert { type: "json" }; -const readPackageJson = async () => { - const contents = await fs.promises.readFile("package.json"); - return JSON.parse(contents); -}; - -// Build the download url from package.json -const getDownloadUrl = (packageJson) => { - const pkgName = packageJson.name; - const version = packageJson.version; - const repo = packageJson.repository; - const url = `https://github.com/${repo}/releases/download/v${version}/${pkgName}_${platform}_${arch}.tar.gz`; - return url; -}; - -const fetchAndParseCheckSumFile = async (packageJson, agent) => { - const version = packageJson.version; - const pkgName = packageJson.name; - const repo = packageJson.repository; - const checksumFileUrl = `https://github.com/${repo}/releases/download/v${version}/${pkgName}_${version}_checksums.txt`; - - // Fetch the checksum file - console.info("Downloading", checksumFileUrl); - const response = await fetch(checksumFileUrl, { agent }); - if (response.ok) { - const checkSumContent = await response.text(); - const lines = checkSumContent.split("\n"); - - const checksums = {}; - for (const line of lines) { - const [checksum, packageName] = line.split(/\s+/); - checksums[packageName] = checksum; - } - - return checksums; - } else { - console.error( - "Could not fetch checksum file", - response.status, - response.statusText - ); - } -}; - -const errGlobal = `Installing Supabase CLI as a global module is not supported. -Please use one of the supported package managers: https://github.com/supabase/cli#install-the-cli -`; -const errChecksum = "Checksum mismatch. Downloaded data might be corrupted."; -const errUnsupported = `Installation is not supported for ${process.platform} ${process.arch}`; - -/** - * Reads the configuration from application's package.json, - * downloads the binary from package url and stores at - * ./bin in the package's root. - * - * See: https://docs.npmjs.com/files/package.json#bin - */ -async function main() { - const yarnGlobal = JSON.parse( - process.env.npm_config_argv || "{}" - ).original?.includes("global"); - if (process.env.npm_config_global || yarnGlobal) { - throw errGlobal; - } - if (!arch || !platform) { - throw errUnsupported; - } - - // Read from package.json and prepare for the installation. - const pkg = await readPackageJson(); - if (platform === "windows") { - // Update bin path in package.json - pkg.bin[pkg.name] += ".exe"; - } - - // Prepare the installation path by creating the directory if it doesn't exist. - const binPath = pkg.bin[pkg.name]; - const binDir = path.dirname(binPath); - await fs.promises.mkdir(binDir, { recursive: true }); - - // Create the agent that will be used for all the fetch requests later. - const proxyUrl = - process.env.npm_config_https_proxy || - process.env.npm_config_http_proxy || - process.env.npm_config_proxy; - // Keeps the TCP connection alive when sending multiple requests - // Ref: https://github.com/node-fetch/node-fetch/issues/1735 - const agent = proxyUrl - ? new HttpsProxyAgent(proxyUrl, { keepAlive: true }) - : new Agent({ keepAlive: true }); - - // First, fetch the checksum map. - const checksumMap = await fetchAndParseCheckSumFile(pkg, agent); - - // Then, download the binary. - const url = getDownloadUrl(pkg); - console.info("Downloading", url); - const resp = await fetch(url, { agent }); - const hash = createHash("sha256"); - const pkgNameWithPlatform = `${pkg.name}_${platform}_${arch}.tar.gz`; - - // Then, decompress the binary -- we will first Un-GZip, then we will untar. - const ungz = zlib.createGunzip(); - const binName = path.basename(binPath); - const untar = extract({ cwd: binDir }, [binName]); - - // Update the hash with the binary data as it's being downloaded. - resp.body - .on("data", (chunk) => { - hash.update(chunk); - }) - // Pipe the data to the ungz stream. - .pipe(ungz); - - // After the ungz stream has ended, verify the checksum. - ungz - .on("end", () => { - const expectedChecksum = checksumMap?.[pkgNameWithPlatform]; - // Skip verification if we can't find the file checksum - if (!expectedChecksum) { - console.warn("Skipping checksum verification"); - return; - } - const calculatedChecksum = hash.digest("hex"); - if (calculatedChecksum !== expectedChecksum) { - throw errChecksum; - } - console.info("Checksum verified."); - }) - // Pipe the data to the untar stream. - .pipe(untar); - - // Wait for the untar stream to finish. - await new Promise((resolve, reject) => { - untar.on("error", reject); - untar.on("end", () => resolve()); - }); - - // Link the binaries in postinstall to support yarn - await binLinks({ - path: path.resolve("."), - pkg: { ...pkg, bin: { [pkg.name]: binPath } }, - }); - - console.info("Installed Supabase CLI successfully"); -} - -await main(); From a3a7e68f91ceb1ded212a0391a073be5c67f50c7 Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 18 Nov 2025 01:15:47 +0800 Subject: [PATCH 2/4] chore: rm temp --- bin/supabase.js | 62 ------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 bin/supabase.js diff --git a/bin/supabase.js b/bin/supabase.js deleted file mode 100644 index d680cf7bb..000000000 --- a/bin/supabase.js +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env node - -/** - * Wrapper script that delegates to the platform-specific binary. - * The actual binary is provided by one of the optional dependencies: - * - supabase-darwin-amd64 - * - supabase-darwin-arm64 - * - supabase-linux-amd64 - * - supabase-linux-arm64 - * - supabase-windows-amd64 - * - supabase-windows-arm64 - */ - -import { spawnSync } from "child_process"; -import { dirname, join } from "path"; -import { fileURLToPath } from "url"; - -const __dirname = dirname(fileURLToPath(import.meta.url)); - -// Mapping from Node's process.arch to package names -const ARCH_MAPPING = { - x64: "amd64", - arm64: "arm64", -}; - -// Mapping from Node's process.platform to package names -const PLATFORM_MAPPING = { - darwin: "darwin", - linux: "linux", - win32: "windows", -}; - -const arch = ARCH_MAPPING[process.arch]; -const platform = PLATFORM_MAPPING[process.platform]; - -if (!arch || !platform) { - console.error(`Unsupported platform: ${process.platform} ${process.arch}`); - process.exit(1); -} - -// Construct the package name -const packageName = `supabase-${platform}-${arch}`; - -// Construct the path to the binary -// The binary is in node_modules/{packageName}/bin/supabase[.exe] -const binaryName = platform === "windows" ? "supabase.exe" : "supabase"; -const binaryPath = join( - __dirname, - "..", - "node_modules", - packageName, - "bin", - binaryName, -); - -// Run the binary with all arguments -const result = spawnSync(binaryPath, process.argv.slice(2), { - stdio: "inherit", -}); - -// Exit with the same code as the binary -process.exit(result.status ?? 1); From 6234d429dfa9f8cf621507c40484d95afba146e6 Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 18 Nov 2025 02:18:11 +0800 Subject: [PATCH 3/4] chore: go generate --- pkg/api/types.gen.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index 267dfb1cd..de8a574e3 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -2942,8 +2942,13 @@ type OrganizationProjectsResponseProjectsStatus string // OrganizationResponseV1 defines model for OrganizationResponseV1. type OrganizationResponseV1 struct { + // Id Deprecated: Use `slug` instead. + // Deprecated: Id string `json:"id"` Name string `json:"name"` + + // Slug Organization slug + Slug string `json:"slug"` } // PgsodiumConfigResponse defines model for PgsodiumConfigResponse. @@ -3874,8 +3879,12 @@ type V1CreateProjectBody struct { // Name Name of your project Name string `json:"name"` - // OrganizationId Slug of your organization - OrganizationId string `json:"organization_id"` + // OrganizationId Deprecated: Use `organization_slug` instead. + // Deprecated: + OrganizationId *string `json:"organization_id,omitempty"` + + // OrganizationSlug Organization slug + OrganizationSlug string `json:"organization_slug"` // Plan Subscription Plan is now set on organization level and is ignored in this request // Deprecated: @@ -4142,9 +4151,13 @@ type V1ProjectResponse struct { // Name Name of your project Name string `json:"name"` - // OrganizationId Slug of your organization + // OrganizationId Deprecated: Use `organization_slug` instead. + // Deprecated: OrganizationId string `json:"organization_id"` + // OrganizationSlug Organization slug + OrganizationSlug string `json:"organization_slug"` + // Ref Project ref Ref string `json:"ref"` @@ -4181,9 +4194,13 @@ type V1ProjectWithDatabaseResponse struct { // Name Name of your project Name string `json:"name"` - // OrganizationId Slug of your organization + // OrganizationId Deprecated: Use `organization_slug` instead. + // Deprecated: OrganizationId string `json:"organization_id"` + // OrganizationSlug Organization slug + OrganizationSlug string `json:"organization_slug"` + // Ref Project ref Ref string `json:"ref"` From d2a787415c2b51fe653de3125ec88ace3cf60783 Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 18 Nov 2025 02:29:26 +0800 Subject: [PATCH 4/4] chore: go build --- cmd/projects.go | 2 +- internal/projects/create/create.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/projects.go b/cmd/projects.go index 4ba28f08f..f1e5e27de 100644 --- a/cmd/projects.go +++ b/cmd/projects.go @@ -76,7 +76,7 @@ var ( } body := api.V1CreateProjectBody{ Name: projectName, - OrganizationId: orgId, + OrganizationId: &orgId, DbPass: dbPassword, Region: cast.Ptr(api.V1CreateProjectBodyRegion(region.Value)), } diff --git a/internal/projects/create/create.go b/internal/projects/create/create.go index 9b8e03d1a..25ba22399 100644 --- a/internal/projects/create/create.go +++ b/internal/projects/create/create.go @@ -64,11 +64,13 @@ func promptMissingParams(ctx context.Context, body *api.V1CreateProjectBody) err } else { fmt.Fprintln(os.Stderr, printKeyValue("Creating project", body.Name)) } - if len(body.OrganizationId) == 0 { - if body.OrganizationId, err = promptOrgId(ctx); err != nil { + if body.OrganizationId == nil || len(*body.OrganizationId) == 0 { + orgId, err := promptOrgId(ctx) + if err != nil { return err } - fmt.Fprintln(os.Stderr, printKeyValue("Selected org-id", body.OrganizationId)) + body.OrganizationId = &orgId + fmt.Fprintln(os.Stderr, printKeyValue("Selected org-id", *body.OrganizationId)) } if body.Region == nil || len(*body.Region) == 0 { region, err := promptProjectRegion(ctx)