Skip to content

feat(go): add Go SDK for Phala Cloud API#212

Merged
Leechael merged 8 commits intomainfrom
feat-golang-sdk
Mar 18, 2026
Merged

feat(go): add Go SDK for Phala Cloud API#212
Leechael merged 8 commits intomainfrom
feat-golang-sdk

Conversation

@Leechael
Copy link
Collaborator

Summary

  • New sdks/go/ package (phala) — flat package, functional options client
  • Covers all non-on-chain-KMS API surface: auth, CVMs (CRUD + lifecycle + patch), compose/config, KMS, SSH keys, workspaces, apps, nodes, instance types, OS images, batch status
  • SSE streaming (WatchCVMState), retry with exponential backoff (409/429/503)
  • CVM ID resolution supporting all formats: int, UUID, app_id (40-char hex), hashed ID, name
  • X25519 + AES-GCM env encryption for UpdateCVMEnvs / PatchCVM
  • Full E2E test suite (go:build e2e) matching Python SDK coverage — all 17 subtests pass

Test plan

  • go build ./... — compiles clean
  • go vet ./... — no issues
  • go test -tags e2e -v -count=1 -timeout 30m ./... — all pass (~17min)

Flat package `phala` with functional options client, covering all
non-on-chain-KMS API surface:

- Auth, CVMs (CRUD + lifecycle + patch), compose/config management
- KMS, SSH keys, workspaces, apps, nodes, instance types, OS images
- SSE streaming (WatchCVMState), retry with exponential backoff
- CVM ID resolution (int, UUID, app_id, hashed, name)
- X25519+AES-GCM env encryption for UpdateCVMEnvs/PatchCVM
- Full E2E test suite (go:build e2e) matching Python SDK coverage
Avoid unnecessary sleep (up to 20s) when the last retry fails and
no more attempts will be made.
- Fix default base URL to https://cloud-api.phala.com/api/v1
- Make RestartCVM force parameter configurable (default false)
- Add overwrite/dry_run options to RefreshCVMInstanceID
- Add full filtering options to RefreshCVMInstanceIDs
- Move e2e_test.go to e2e/ subdirectory with its own go.mod
- Use external package import pattern for cleaner separation
- Add comprehensive README.md with usage examples
- Add unit tests for client, errors, helpers, and retry logic
- Fix gofmt formatting in source and test files
- Add Go pre-commit hooks (gofmt, go vet, go test) to sdks config
Module path: github.com/Phala-Network/phala-cloud/sdks/go
Release tag format: sdks/go/v0.x.x
- Rename release-command.yml → release-npm.yml (JS & CLI)
- Add release-go.yml for Go SDK releases via `!release go <type>`
- Add bump-go-version.sh for semver version bumping
- Each workflow silently skips packages it doesn't own
- Go releases use git tag `sdks/go/vX.Y.Z` for Go module proxy
MaxRetries was an int defaulting to 0, causing no retries on failure.
Changed to *int where nil means unlimited retries, matching JS/Python.
@Leechael
Copy link
Collaborator Author

!release go patch

@github-actions
Copy link
Contributor

⚠️ @Leechael I couldn't parse the release command.

Expected format: !release <cli|js|python> <patch|minor|major> [beta|alpha|rc]

Examples:

  • !release cli patch - stable release
  • !release js minor beta - beta release
  • !release python minor - Python SDK release

@Leechael Leechael merged commit a94c7d5 into main Mar 18, 2026
2 checks passed
@Leechael Leechael deleted the feat-golang-sdk branch March 18, 2026 12:30
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