Skip to content

Vendor the API client into the CLI, drop the planetscale-go dependency#1286

Open
no-itsbackpack wants to merge 13 commits into
mainfrom
remove-planetscale-go-dependancy
Open

Vendor the API client into the CLI, drop the planetscale-go dependency#1286
no-itsbackpack wants to merge 13 commits into
mainfrom
remove-planetscale-go-dependancy

Conversation

@no-itsbackpack

Copy link
Copy Markdown
Contributor

Problem:

Every API change in the CLI required touching two repos. You had to add the new endpoint to planetscale-go, get that PR merged, tag a release, bump the version in the CLI's go.mod, and only then start the actual CLI work. The CLI is the only thing here that consumes planetscale-go, so this release dance added overhead to every feature without buying us anything.

Solution:

Copy the API client from planetscale-go (v0.175.0, the exact version we were pinned to) into this repo at internal/planetscale/ and remove the module dependency. Adding or changing an endpoint is now a normal change in this repo, done in the same PR as the feature that needs it.

Details:

  • The client code is byte-for-byte the v0.175.0 release, including its tests. Only the import path changed, plus the User-Agent handling below.
  • All ~290 files that imported github.com/planetscale/planetscale-go/planetscale now import github.com/planetscale/cli/internal/planetscale. The package name is unchanged so no call sites moved.
  • The User-Agent header is now just pscale-cli/<version>. The old second token (planetscale-go/<version>) no longer means anything since the client version is the CLI version.
  • doc/api-client.md explains the new workflow for contributors and coding agents, and AGENTS.md links to it so nobody reintroduces the two-repo process out of habit.

The planetscale-go repo itself is not touched by this PR. It still exists for external users of the Go SDK; its future is a separate conversation.


Security impact:

None expected. No new dependencies, no auth changes, no behavior changes to requests other than the User-Agent string.


Testing:

  • go build ./... and the full go test ./... suite pass, including the vendored client's own tests.
  • Built the binary and confirmed it runs.

no-itsbackpack and others added 4 commits July 8, 2026 16:16
The CLI was the only internal consumer of planetscale-go, and every API
change required a second PR plus a release/tag/bump cycle there before
CLI work could start. Copy the client (v0.175.0) into the repo and drop
the module dependency so API changes land in a single CLI PR.

The User-Agent now reports pscale-cli/<version> only; the separate
library version token is gone since the client version is the CLI
version.

Co-authored-by: Cursor <cursoragent@cursor.com>
doc/api-client.md explains why the planetscale-go dependency was
removed and how to add endpoints now; AGENTS.md points developers at it
so nobody reintroduces the two-repo workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Brings in the WithReplication field on PostgresRole and
CreatePostgresRoleRequest, the only change between v0.175.0 and
v0.176.0.

Co-authored-by: Cursor <cursoragent@cursor.com>
no-itsbackpack and others added 5 commits July 8, 2026 16:51
Co-authored-by: Cursor <cursoragent@cursor.com>
…client branch.

Co-authored-by: Cursor <cursoragent@cursor.com>
v0.178.0 splits BranchInfrastructure into Vitess and Postgres variants
with a JSON discriminator and adds GlobalKeyspace to move-tables
requests. Main's postgres-branch-infra change (#1287) consumes the new
types; go.mod keeps the dependency removed.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ut).

Co-authored-by: Cursor <cursoragent@cursor.com>
The API client is vendored at internal/planetscale, so the external
module must not come back. This test fails if planetscale-go appears in
go.mod or in any import, and points offenders at doc/api-client.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
@no-itsbackpack no-itsbackpack marked this pull request as ready for review July 9, 2026 17:13
@no-itsbackpack no-itsbackpack requested a review from a team as a code owner July 9, 2026 17:13
no-itsbackpack and others added 3 commits July 9, 2026 12:51
Keep planetscale-go's WithUserAgent prepend semantics and build-info
default instead of the CLI-specific variant. This makes every file in
internal/planetscale identical to upstream, so mirroring back to
planetscale-go is a plain copy with no carried patches. The CLI's
User-Agent still leads with pscale-cli/<version>.

The dependency guard test now parses imports with go/parser instead of
substring matching, since the restored client.go mentions the module
path in a comment and a string literal.

Co-authored-by: Cursor <cursoragent@cursor.com>
The vendored client is canonical; planetscale-go becomes a read-only
mirror for external module users. On CLI releases (or manually) the
workflow copies internal/planetscale into planetscale-go, builds and
tests it standalone, and opens a PR there with a gorelease API report.
It never pushes to main, so a human reviews and picks the next tag.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fe792c9. Configure here.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mirror skips PR after push

Low Severity

When the mirror branch already exists on planetscale-go, the commit step exits successfully and later steps skip opening a pull request. A rerun after a failed gh pr create (or push without PR) leaves the mirror updated on the remote branch with no PR and no recovery path in the workflow.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fe792c9. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants