Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
281fa92
Vendor the API client from planetscale-go into internal/planetscale.
no-itsbackpack Jul 8, 2026
7ada02e
Document the vendored API client for agents and contributors.
no-itsbackpack Jul 8, 2026
0d1f4ed
Fix import grouping after the client import path rewrite (go fmt).
no-itsbackpack Jul 8, 2026
9c2f6d1
Sync the vendored client to planetscale-go v0.176.0.
no-itsbackpack Jul 8, 2026
2c893ad
Retrigger CI.
no-itsbackpack Jul 8, 2026
320acc1
Merge origin/main (postgres role with-replication) into the vendored-…
no-itsbackpack Jul 8, 2026
a453e9d
Sync the vendored client to planetscale-go v0.178.0 and merge main.
no-itsbackpack Jul 9, 2026
89bc30a
Promote go-humanize to a direct dependency (used by branch infra outp…
no-itsbackpack Jul 9, 2026
3b58255
Add test guarding against reintroducing planetscale-go
no-itsbackpack Jul 9, 2026
cc14ba6
Merge branch 'main' into remove-planetscale-go-dependancy
no-itsbackpack Jul 9, 2026
a973291
Restore upstream client.go so the vendored copy is byte-identical
no-itsbackpack Jul 9, 2026
1eb0099
Add workflow mirroring the client back to planetscale-go
no-itsbackpack Jul 9, 2026
fe792c9
Merge remote branch (main merged, includes d1 sqlite3 fix)
no-itsbackpack Jul 9, 2026
821ffa1
Use the CLI GitHub App for mirror auth
no-itsbackpack Jul 9, 2026
63882ee
Temporarily trigger mirror workflow on branch push for testing
no-itsbackpack Jul 9, 2026
b8364d8
Run mirror job in the release environment for app credentials
no-itsbackpack Jul 9, 2026
f616b4f
Keep internal API endpoints out of the planetscale-go mirror
no-itsbackpack Jul 9, 2026
c21deca
Rename mirror workflow and script to sync-planetscale-go
no-itsbackpack Jul 9, 2026
81724b6
Skip deployment records for the sync job's environment use
no-itsbackpack Jul 9, 2026
5838b9c
Fetch tags in planetscale-go checkout so gorelease finds its base
no-itsbackpack Jul 9, 2026
f96daec
Remove temporary push trigger now that the sync workflow is verified
no-itsbackpack Jul 9, 2026
adee0bd
Merge main: global-keyspace move-tables works against the vendored cl…
no-itsbackpack Jul 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
143 changes: 143 additions & 0 deletions .github/workflows/sync-planetscale-go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Sync client to planetscale-go

# The API client at internal/planetscale is canonical (see doc/api-client.md).
# This workflow copies it into planetscale/planetscale-go and opens a PR there
# so external users of the module can pick up new endpoints. It never pushes
# to main directly: a human reviews the PR, including the gorelease API report,
# and decides the version to tag.
#
# Auth comes from the CLI GitHub App (same as release.yml); the app must be
# installed on planetscale-go with contents and pull request write access.

on:
workflow_dispatch:
release:
types: [published]

permissions:
contents: read

jobs:
sync:
runs-on: ubuntu-latest
# The CLI app credentials (CLI_APP_ID, CLI_APP_PRIVATE_KEY) are scoped to
# the release environment. This job only reads secrets and deploys
# nothing, so skip creating deployment records.
environment:
name: release
deployment: false
steps:
- uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
id: app-token
with:
app-id: ${{ vars.CLI_APP_ID }}
private-key: ${{ secrets.CLI_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write
owner: planetscale
repositories: planetscale-go

- name: Check out cli
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: cli

- name: Check out planetscale-go
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: planetscale/planetscale-go
token: ${{ steps.app-token.outputs.token }}
path: planetscale-go
# gorelease needs the tag history to find the base version.
fetch-depth: 0
fetch-tags: true

- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: cli/go.mod

- name: Sync client files
run: ./cli/script/sync-planetscale-go.sh cli planetscale-go

- name: Check for changes
id: changes
working-directory: planetscale-go
run: |
if git diff --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "planetscale-go is already up to date"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
git diff --stat
fi
Comment thread
cursor[bot] marked this conversation as resolved.

- name: Build and test synced copy
if: steps.changes.outputs.changed == 'true'
working-directory: planetscale-go
run: |
go mod tidy
go build ./...
go test ./...

- name: Commit to sync branch
if: steps.changes.outputs.changed == 'true'
id: commit
working-directory: planetscale-go
run: |
source_sha=$(git -C ../cli rev-parse --short HEAD)
branch="sync-cli-${source_sha}"
echo "branch=$branch" >> "$GITHUB_OUTPUT"
if git ls-remote --exit-code origin "refs/heads/$branch" > /dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Branch $branch already exists, nothing to do"
exit 0
Comment thread
cursor[bot] marked this conversation as resolved.
fi
echo "exists=false" >> "$GITHUB_OUTPUT"
git config user.name "planetscale-cli[bot]"
git config user.email "272331943+planetscale-cli[bot]@users.noreply.github.com"
git checkout -b "$branch"
git add -A
git commit -m "Sync API client from planetscale/cli@${source_sha}"

- name: API compatibility report
if: steps.changes.outputs.changed == 'true' && steps.commit.outputs.exists == 'false'
working-directory: planetscale-go
run: |
# gorelease requires a clean tree, hence running after the commit.
go install golang.org/x/exp/cmd/gorelease@latest
base=$(git describe --tags --abbrev=0)
echo "Comparing against $base"
Comment thread
cursor[bot] marked this conversation as resolved.
{
echo '## gorelease report (base: '"$base"')'
echo '```'
gorelease -base="$base" 2>&1 || true
echo '```'
} > /tmp/gorelease-report.md
cat /tmp/gorelease-report.md

- name: Open pull request
if: steps.changes.outputs.changed == 'true' && steps.commit.outputs.exists == 'false'
working-directory: planetscale-go
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
source_sha=$(git -C ../cli rev-parse --short HEAD)
branch="${{ steps.commit.outputs.branch }}"
git push origin "$branch"
{
echo "Automated sync of the API client from planetscale/cli@${source_sha}."
echo
echo "The client in the cli repo (internal/planetscale) is the source of"
echo "truth; this repo is a read-only mirror for external module users."
echo
echo "Review the API report below before merging. If it lists incompatible"
echo "changes, the next tag needs to reflect that."
echo
cat /tmp/gorelease-report.md
} > /tmp/pr-body.md
gh pr create \
--repo planetscale/planetscale-go \
--head "$branch" \
--title "Sync API client from cli@${source_sha}" \
--body-file /tmp/pr-body.md
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# PlanetScale CLI — agent guide

> **Developing the CLI?** The API client is vendored at `internal/planetscale/`;
> this repo **no longer depends on `planetscale-go`**. Read `doc/api-client.md`
> before touching API-facing code. The rest of this file is about *using* `pscale`.

For **any** automated agent or script using `pscale`. Always pass **`--format json`**. Substitute placeholders from the user's request or from prior command output (`org list`, `database list`, `branch list`).

If you only have the installed `pscale` binary, start here:
Expand Down
70 changes: 70 additions & 0 deletions doc/api-client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# API client (`internal/planetscale`)

**The CLI no longer depends on `github.com/planetscale/planetscale-go`.**

As of July 2026, the Go API client that used to live in the planetscale-go
repository is vendored into this repo at `internal/planetscale/` and is
maintained here. The import path is:

```go
import ps "github.com/planetscale/cli/internal/planetscale"
```

## Why

Every API change used to require two PRs and a release dance: change
planetscale-go, tag a release, bump `go.mod` here, then write the CLI
feature. The CLI was the only internal consumer of planetscale-go, and the
published OpenAPI spec covers under half of the endpoints the CLI uses
(none of the vtctld/workflow/data-import surface), so generating a client
from the spec was not an option. Copying the client in removes the
cross-repo step entirely.

## What this means when adding or changing an endpoint

- Add the endpoint to api-bb, then add the method/types directly in
`internal/planetscale/` in the same CLI PR. There is no SDK release to
wait for and no version to bump.
- Do **not** add `github.com/planetscale/planetscale-go` back to `go.mod`,
and do not update the planetscale-go repo as a prerequisite for CLI work.
A test (`TestNoPlanetscaleGoDependency` in `internal/planetscale/`) fails
the build if the module shows up in `go.mod` or in any import.
- Service interfaces (e.g. `DatabasesService`) live next to their
implementations; hand-written mocks are in `internal/mock/` and must be
updated when an interface changes, same as before.
- The client's `User-Agent` starts with `pscale-cli/<version>`, set by the
CLI at startup via `planetscale.WithUserAgent` (see `internal/cmd/root.go`).
`WithUserAgent` keeps upstream's prepend semantics so the package stays
byte-identical to what the sync publishes (see below); the full header
is `pscale-cli/<version> planetscale-go/unknown`.
- Keep this package self-contained: do not import other CLI packages from
`internal/planetscale/`. The synced copy must build against
planetscale-go's own minimal `go.mod`.
- Only public (`v1/...`) endpoints are synced to planetscale-go. If the
CLI needs an internal (non-v1) endpoint, put the whole service in a
`*_internal.go` file (tests in `*_internal_test.go`); the sync script
skips those. Internal services must not be wired into the `Client`
struct in `client.go`, since that file is synced: expose them via a
method or constructor defined in the internal file itself. If a synced
file accidentally references an internal symbol, the sync workflow's
standalone build fails, so mistakes cannot ship silently.
(`d1_import_notifications.go` predates this rule: it hits an internal
endpoint but is already published in planetscale-go, so it stays.)

## The planetscale-go repository

The public planetscale-go module still exists for external users, but it
is now a read-only mirror of this package. The CLI copy is the source of
truth; do not make client changes in the planetscale-go repo.

The sync is the `Sync client to planetscale-go` workflow
(`.github/workflows/sync-planetscale-go.yml`), which uses
`script/sync-planetscale-go.sh`. It runs on CLI releases
or manually, copies `internal/planetscale/` into planetscale-go (minus
`doc.go`, `dependency_test.go`, and `*_internal.go` files, which are
CLI-only), builds and tests
the copy standalone, and opens a PR there with a `gorelease` API
compatibility report. It never pushes to main: a human reviews the PR and
picks the next tag, bumping the major version if the report shows
incompatible changes. Auth comes from the CLI GitHub App (the same one
release.yml uses), which must be installed on planetscale-go.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/muesli/termenv v0.16.0
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/planetscale/planetscale-go v0.178.0
github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4
github.com/planetscale/psdbproxy v0.0.0-20250728082226-3f4ea3a74ec7
github.com/spf13/cobra v1.10.2
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjL
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e h1:MZ8D+Z3m2vvqGZLvoQfpaGg/j1fNDr4j03s3PRz4rVY=
github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e/go.mod h1:hwAsSPQdvPa3WcfKfzTXxtEq/HlqwLjQasfO6QbGo4Q=
github.com/planetscale/planetscale-go v0.178.0 h1:1a+VwVpvV4eAFaeL1bLCPcnWKItuYTSBfD2s8BN+6To=
github.com/planetscale/planetscale-go v0.178.0/go.mod h1:paQCI5SgquuoewvMQM7R+r1XJO868bdP6/ihGidYRM0=
github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4 h1:Xv5pj20Rhfty1Tv0OVcidg4ez4PvGrpKvb6rvUwQgDs=
github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4/go.mod h1:M52h5IWxAcbdQ1hSZrLAGQC4ZXslxEsK/Wh9nu3wdWs=
github.com/planetscale/psdbproxy v0.0.0-20250728082226-3f4ea3a74ec7 h1:aRd6vdE1fyuSI4RVj7oCr8lFmgqXvpnPUmN85VbZCp8=
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/auditlog/auditlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"golang.org/x/text/cases"
"golang.org/x/text/language"

ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
)

// AuditLogCmd handles audit logs.
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/auditlog/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/url"

"github.com/planetscale/cli/internal/cmdutil"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

"github.com/pkg/browser"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/auditlog/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
psauth "github.com/planetscale/cli/internal/auth"
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
"github.com/planetscale/planetscale-go/planetscale"

"github.com/fatih/color"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/spf13/cobra"

ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
)

// BackupCmd handles branch backups.
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"

"github.com/planetscale/cli/internal/cmdutil"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/printer"

"github.com/planetscale/planetscale-go/planetscale"
"github.com/planetscale/cli/internal/planetscale"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"

"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
"github.com/planetscale/planetscale-go/planetscale"

"github.com/pkg/browser"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/printer"

"github.com/planetscale/planetscale-go/planetscale"
"github.com/planetscale/cli/internal/planetscale"

"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/printer"

"github.com/planetscale/planetscale-go/planetscale"
"github.com/planetscale/cli/internal/planetscale"

"github.com/pkg/browser"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/backup/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/planetscale/cli/internal/cmdutil"
"github.com/planetscale/cli/internal/config"
"github.com/planetscale/cli/internal/mock"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/planetscale/cli/internal/printer"
ps "github.com/planetscale/planetscale-go/planetscale"

qt "github.com/frankban/quicktest"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/branch/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/planetscale/cli/internal/cmd/branch/vtctld"
"github.com/planetscale/cli/internal/cmdutil"
ps "github.com/planetscale/planetscale-go/planetscale"
ps "github.com/planetscale/cli/internal/planetscale"
"github.com/spf13/cobra"
)

Expand Down
Loading