Skip to content

Migrate CLI to v1 public API; retire v1beta1 and v1alpha1 (except IDE)#2093

Draft
jeremybeard wants to merge 4 commits intomainfrom
remove-v1beta1
Draft

Migrate CLI to v1 public API; retire v1beta1 and v1alpha1 (except IDE)#2093
jeremybeard wants to merge 4 commits intomainfrom
remove-v1beta1

Conversation

@jeremybeard
Copy link
Copy Markdown
Contributor

@jeremybeard jeremybeard commented Apr 17, 2026

Summary

Retires the astro-client-core (v1alpha1), astro-client-iam-core (iam/v1beta1), and astro-client-platform-core (platform/v1beta1) generated clients in favor of a single unified astro-client-v1 client built from the public versioned/v1.0 spec released in astronomer/astro#37986.

  • New: astro-client-v1/ — unified client, tags for Organization/Workspace/Cluster/Deployment/Deploy/User/Team/ApiToken/Environment/Authorization/etc.
  • Renamed: astro-client-core/astro-client-v1alpha1/, shrunk to IDE-only (Polaris Project, Polaris Session tags).
  • Deleted: astro-client-iam-core/, astro-client-platform-core/, cloud/platformclient/.
  • Two endpoints stay on v1alpha1 because the server has no v1 equivalent: private/v1alpha1/cli/auth-config (pkg/astroauth/config.go) and /v1alpha1/telemetry (pkg/telemetry/telemetry.go).
  • Legacy tests (22 files) fully migrated; dead cmd-layer test paths covering collapsed split-client APIs were dropped (service-layer coverage remains).

Net diff vs main: 101 files changed, +30,845 / −62,765.

Notable production fixes surfaced during migration

  • cloud/deployment/inspect/inspect.go: format DeploymentEnvironmentVariable.UpdatedAt as RFC3339 before mapstructure decode (v1 changed the field from string to time.Time; inspect was broken for any deployment with env vars).
  • cmd/cloud/deployment.go: uppercase --cloud-provider input before validating against the ClusterCloudProvider enum (AWS/GCP/AZURE) so lowercase input keeps working.

Deferred (marked with TODOs / test skips)

  • Deploy git metadata is currently stubbed out of CreateDeployRequest pending v1 server-side support (one bundle-deploy test is t.Skipped).

Test plan

  • go build ./... clean
  • make lint clean
  • go test ./... passes
  • Live smoke against a local astro instance:
    • astro login (v1 /users/self)
    • astro organization list / switch
    • astro workspace list / switch
    • astro deployment list / create / update / delete / logs
    • astro deployment token list / create; astro workspace token …; astro organization token …
    • astro deployment team list / astro workspace team list (new workspaceId / deploymentId query params)
    • astro ide project list / export / import (still on v1alpha1)
    • astro api cloud … regression

Swaps the three generated clients (astro-client-core,
astro-client-iam-core, astro-client-platform-core) for a single
astro-client-v1 against the versioned v1.0 public API, and shrinks
astro-client-v1alpha1 to the IDE (Polaris Project / Polaris Session)
tags - the only area the v1 spec does not yet cover.

Structural adaptations required by v1:
- ApiToken: scope is carried on the token itself; per-scope
  create/update/rotate/delete endpoints collapse to CreateApiToken /
  UpdateApiToken / UpdateApiTokenRoles / RotateApiToken /
  DeleteApiToken. Token creation is now a two-step CreateApiToken +
  UpdateApiTokenRoles flow.
- Users/teams: role mutations go through UpdateUserRoles /
  UpdateTeamRoles with full-role-set replacement (read-modify-write).
- Deployment create/update: most optional fields are pointer-typed;
  helpers ptrOf, ConvertCreateQueuesToUpdate, and
  ConvertHybridQueuesToUpdate absorb the shape changes.
- Deployment: WorkloadIdentity -> EffectiveWorkloadIdentity.
- Deploys: UpdateDeploy(BundleTarballVersion) -> FinalizeDeploy.
- Deploy git metadata: v1 has no equivalent yet;
  retrieveLocalGitMetadata returns a local struct and the Git field is
  not attached to CreateDeployRequest. TODO(v1-migration) markers flag
  this for a future PR that re-enables the feature once the server
  exposes it.

Endpoints with no v1 equivalent stay pinned on v1alpha1 and are
marked with TODO(v1-migration) comments:
- pkg/astroauth/config.go (AuthConfigEndpoint)
- pkg/telemetry/telemetry.go (TelemetryAPIURL)

Generated client tooling:
- scripts/patch-v1-gen.sh strips invalid auto-setter lines that
  oapi-codegen emits for v1 discriminator children whose 'type'
  property is no longer listed as required.
- .mockery.yaml targets astro-client-v1 and astro-client-v1alpha1.

Test migration: test files that reference v1alpha1 types are tagged
with '//go:build v1_migration_legacy_tests' and will be re-enabled as
each package's tests are adapted to v1. The rest of the test suite
passes.
The IDE client (v1alpha1) no longer exposes GetWorkspace after the
v1alpha1 shrink. Thread the v1 public client into ExportProject ->
resolveProjectID -> createNewProject and reintroduce getWorkspaceName
against v1's GetWorkspace so the "Successfully created project …"
message prints the workspace name again instead of its ID.
Removes the v1_migration_legacy_tests build tag from 22 test files and
brings them onto the unified astrov1 client. Most migrations were
mechanical (imports, unified response types, optional->pointer field
shapes, scoped ApiToken/UserRole models, WorkerQueueRequest vs
UpdateWorkerQueueRequest splits).

Test-only changes:
- cmd/cloud/{organization,workspace,deployment}_test.go: dropped
  user/team/token cases whose split-client API no longer exists
  (unified under ListUsers/UpdateUserRoles/ListTeams/UpdateTeamRoles/
  ListApiTokens/UpdateApiToken). Service-layer coverage at
  cloud/{user,team,organization,workspace-token,deployment}/ now
  exercises this logic.
- cloud/deploy/bundle_test.go: skip TestBundleDeploy_GitMetadataRetrieved
  while v1 CreateDeployRequest lacks Git metadata support.
- cloud/workspace-token: one subtest skipped (unreachable error branch
  in unified flow).

Production fixes surfaced by tests:
- cloud/deployment/inspect/inspect.go: format DeploymentEnvironmentVariable
  UpdatedAt as RFC3339 string before handing it to the mapstructure
  target (v1 type changed from string to time.Time; inspect output
  was broken for any deployment with env vars).
- cmd/cloud/deployment.go: uppercase the --cloud-provider flag value
  before validating against ClusterCloudProvider enum constants (AWS,
  GCP, AZURE) so lowercase input keeps working.
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.

1 participant