Migrate API from v1alpha1 to v1beta1#385
Conversation
WalkthroughMigrate API surface from v1alpha1 to v1beta1: introduce centralized API_VERSION constant in Cypress support, update fixtures/interceptors to use it, change UI constant, update OpenAPI source and JSDoc, and replace Go imports/types/signatures in proxy authentication to v1beta1; update proxy module dependency. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (23)
🚧 Files skipped from review as they are similar to previous changes (13)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings📚 Learning: 2025-01-07T10:11:14.375ZApplied to files:
🧬 Code graph analysis (6)libs/cypress/support/interceptors/enrollmentRequests.ts (2)
libs/cypress/fixtures/auth/organization.ts (2)
libs/cypress/fixtures/fleets/initialFleets.ts (3)
libs/cypress/support/interceptors/devices.ts (2)
proxy/auth/openshift.go (2)
proxy/auth/auth.go (5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (14)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
libs/types/scripts/openapi-typescript.js (1)
19-23: v1beta1 OpenAPI URL looks correct; consider avoiding hard‑coded version stringPointing
swaggerUrlat the v1beta1 spec aligns this generator with the new API version. To reduce churn on the next version bump, consider deriving the version (or full URL) from a shared config/constant used elsewhere in the repo, so this script can’t silently drift from the rest of the tooling.Please double‑check that the backend repo’s canonical spec path is still
api/v1beta1/openapi.yamlbefore cutting a release.libs/ui-components/src/constants.ts (1)
2-2: API version constant update is correct; consider cross‑package centralizationSetting
API_VERSIONto'v1beta1'here aligns the UI with the new API surface and looks good. If the Nx/workspace boundaries allow, you might later centralize this with the CypressAPI_VERSIONconstant to avoid version drift between UI and e2e tests.libs/cypress/support/constants.ts (1)
1-1: API_VERSION constant for Cypress support looks goodDefining
API_VERSION = 'v1beta1'here is a clean way to coordinate versioning across Cypress fixtures/interceptors.If
libs/ui-components/src/constants.tsalso defines anAPI_VERSION, consider wiring Cypress to import from that single source (or re-exporting it here) to avoid the two values drifting in future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
proxy/go.sumis excluded by!**/*.sum
📒 Files selected for processing (23)
libs/cypress/fixtures/auth/organization.ts(1 hunks)libs/cypress/fixtures/enrollmentRequests/index.ts(5 hunks)libs/cypress/fixtures/fleets/initialFleets.ts(3 hunks)libs/cypress/fixtures/repositories/initialRepositories.ts(1 hunks)libs/cypress/support/constants.ts(1 hunks)libs/cypress/support/interceptors/auth.ts(2 hunks)libs/cypress/support/interceptors/devices.ts(1 hunks)libs/cypress/support/interceptors/enrollmentRequests.ts(1 hunks)libs/cypress/support/interceptors/fleets.ts(1 hunks)libs/cypress/support/interceptors/repositories.ts(1 hunks)libs/types/models/ImageApplicationProviderSpec.ts(1 hunks)libs/types/scripts/openapi-typescript.js(1 hunks)libs/ui-components/src/components/AuthProvider/CreateAuthProvider/utils.ts(2 hunks)libs/ui-components/src/constants.ts(1 hunks)proxy/auth/aap.go(2 hunks)proxy/auth/api_client.go(6 hunks)proxy/auth/auth.go(12 hunks)proxy/auth/common.go(2 hunks)proxy/auth/k8s.go(2 hunks)proxy/auth/oauth2.go(2 hunks)proxy/auth/oidc.go(2 hunks)proxy/auth/openshift.go(2 hunks)proxy/go.mod(1 hunks)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: celdrake
Repo: flightctl/flightctl-ui PR: 371
File: libs/types/models/AppType.ts:10-10
Timestamp: 2025-10-29T16:47:29.614Z
Learning: PR #371 (flightctl/flightctl-ui) adds the AppTypeQuadlet enum member and related types as a preparatory change. Full implementation of quadlet application support in the UI will be added later, after backend support is available.
Learnt from: celdrake
Repo: flightctl/flightctl-ui PR: 0
File: :0-0
Timestamp: 2025-02-17T08:41:57.993Z
Learning: All files in `libs/types/models` are auto-generated using OpenAPI Generator from the schema defined in https://github.com/flightctl/flightctl/blob/main/api/v1alpha1/openapi.yaml. Changes to these files should be made in the schema instead of modifying the generated files directly.
📚 Learning: 2025-02-18T12:04:42.579Z
Learnt from: rawagner
Repo: flightctl/flightctl-ui PR: 209
File: apps/standalone/src/app/utils/apiCalls.ts:14-16
Timestamp: 2025-02-18T12:04:42.579Z
Learning: In the flightctl-ui codebase, error handling for API calls follows a React pattern where the caller component (e.g., AppToolbar.tsx) implements try-catch blocks and manages error states, rather than handling errors within the API utility functions themselves.
Applied to files:
libs/cypress/fixtures/enrollmentRequests/index.ts
📚 Learning: 2025-01-07T10:11:14.375Z
Learnt from: rawagner
Repo: flightctl/flightctl-ui PR: 181
File: proxy/config/ocp.go:16-16
Timestamp: 2025-01-07T10:11:14.375Z
Learning: In the flightctl-ui repository, the `RBACNs` variable used in `proxy/config/ocp.go` is defined in `proxy/config/config.go` as a package-level variable that retrieves its value from the environment variable `K8S_RBAC_NS`.
Applied to files:
proxy/auth/aap.goproxy/auth/oidc.goproxy/auth/common.goproxy/auth/oauth2.goproxy/auth/openshift.goproxy/auth/k8s.go
📚 Learning: 2025-11-20T07:33:34.656Z
Learnt from: celdrake
Repo: flightctl/flightctl-ui PR: 378
File: libs/ui-components/src/utils/authProvider.ts:5-18
Timestamp: 2025-11-20T07:33:34.656Z
Learning: In the flightctl-ui repository, for AuthProvider objects, the metadata.name field is always present at runtime as it serves as the ID of the authprovider. The OpenAPI schema incorrectly defines it as optional (name?: string in ObjectMeta), but the type assertion `as string` is appropriate when accessing provider.metadata.name since it's guaranteed to exist.
Applied to files:
proxy/auth/common.golibs/ui-components/src/components/AuthProvider/CreateAuthProvider/utils.ts
📚 Learning: 2025-11-20T09:24:41.991Z
Learnt from: celdrake
Repo: flightctl/flightctl-ui PR: 378
File: libs/ui-components/src/components/AuthProvider/CreateAuthProvider/utils.ts:288-326
Timestamp: 2025-11-20T09:24:41.991Z
Learning: In the flightctl-ui repository, the CreateAuthProvider form and its utilities (including getAuthProvider in libs/ui-components/src/components/AuthProvider/CreateAuthProvider/utils.ts) are specifically designed for CRUD operations on OIDC and OAuth2 authentication providers only. Other provider types (K8s, AAP, OpenShift) are not supported by this form and should be rejected with an error if loading is attempted for editing.
Applied to files:
proxy/auth/common.golibs/ui-components/src/components/AuthProvider/CreateAuthProvider/utils.tsproxy/auth/k8s.go
📚 Learning: 2025-02-17T08:41:57.993Z
Learnt from: celdrake
Repo: flightctl/flightctl-ui PR: 0
File: :0-0
Timestamp: 2025-02-17T08:41:57.993Z
Learning: All files in `libs/types/models` are auto-generated using OpenAPI Generator from the schema defined in https://github.com/flightctl/flightctl/blob/main/api/v1alpha1/openapi.yaml. Changes to these files should be made in the schema instead of modifying the generated files directly.
Applied to files:
proxy/auth/oauth2.golibs/types/scripts/openapi-typescript.js
📚 Learning: 2025-03-12T09:09:44.139Z
Learnt from: celdrake
Repo: flightctl/flightctl-ui PR: 227
File: libs/ui-components/src/components/Device/EditDeviceWizard/EditDeviceWizard.tsx:87-87
Timestamp: 2025-03-12T09:09:44.139Z
Learning: The `getUpdatePolicyValues` function in libs/ui-components/src/components/Fleet/CreateFleet/fleetSpecUtils.ts is designed to safely handle undefined values for the updatePolicy parameter.
Applied to files:
libs/cypress/fixtures/fleets/initialFleets.ts
📚 Learning: 2025-03-12T09:09:44.139Z
Learnt from: celdrake
Repo: flightctl/flightctl-ui PR: 227
File: libs/ui-components/src/components/Device/EditDeviceWizard/EditDeviceWizard.tsx:87-87
Timestamp: 2025-03-12T09:09:44.139Z
Learning: The `getUpdatePolicyValues` function in libs/ui-components/src/components/Fleet/CreateFleet/fleetSpecUtils.ts is designed to handle undefined input through its optional parameter definition and consistent use of optional chaining.
Applied to files:
libs/cypress/fixtures/fleets/initialFleets.ts
📚 Learning: 2025-10-10T11:35:04.458Z
Learnt from: celdrake
Repo: flightctl/flightctl-ui PR: 0
File: :0-0
Timestamp: 2025-10-10T11:35:04.458Z
Learning: In the flightctl-ui repository, TypeScript types are generated using hey-api/openapi-ts and output to a single index.ts file (previously used openapi-typescript-codegen with one file per type under /libs/types/models).
Applied to files:
libs/types/scripts/openapi-typescript.js
📚 Learning: 2025-03-20T12:34:33.199Z
Learnt from: celdrake
Repo: flightctl/flightctl-ui PR: 240
File: libs/types/models/FileSpec.ts:8-8
Timestamp: 2025-03-20T12:34:33.199Z
Learning: Files in the types directory are autogenerated from the OpenAPI spec in the flightctl project and should not be directly modified.
Applied to files:
libs/types/scripts/openapi-typescript.js
📚 Learning: 2025-03-24T12:33:54.002Z
Learnt from: rawagner
Repo: flightctl/flightctl-ui PR: 209
File: proxy/auth/oidc.go:17-19
Timestamp: 2025-03-24T12:33:54.002Z
Learning: OIDC (OpenID Connect) providers return usernames in the `preferred_username` field, as implemented in the OIDCUserInfo struct in proxy/auth/oidc.go.
Applied to files:
proxy/auth/api_client.go
🧬 Code graph analysis (11)
libs/ui-components/src/constants.ts (1)
libs/cypress/support/constants.ts (1)
API_VERSION(1-1)
libs/cypress/fixtures/enrollmentRequests/index.ts (2)
libs/cypress/support/constants.ts (1)
API_VERSION(1-1)libs/ui-components/src/constants.ts (1)
API_VERSION(6-6)
libs/cypress/support/interceptors/enrollmentRequests.ts (2)
libs/cypress/support/constants.ts (1)
API_VERSION(1-1)libs/ui-components/src/constants.ts (1)
API_VERSION(6-6)
libs/cypress/fixtures/repositories/initialRepositories.ts (4)
libs/types/index.ts (1)
Repository(153-153)libs/types/models/Repository.ts (1)
Repository(11-23)libs/cypress/support/constants.ts (1)
API_VERSION(1-1)libs/ui-components/src/constants.ts (1)
API_VERSION(6-6)
libs/cypress/support/interceptors/repositories.ts (2)
libs/cypress/support/constants.ts (1)
API_VERSION(1-1)libs/ui-components/src/constants.ts (1)
API_VERSION(6-6)
libs/cypress/support/constants.ts (1)
libs/ui-components/src/constants.ts (1)
API_VERSION(6-6)
libs/cypress/fixtures/auth/organization.ts (2)
libs/cypress/support/constants.ts (1)
API_VERSION(1-1)libs/ui-components/src/constants.ts (1)
API_VERSION(6-6)
proxy/auth/api_client.go (5)
libs/types/models/TokenRequest.ts (1)
TokenRequest(8-37)libs/types/index.ts (3)
TokenRequest(184-184)TokenResponse(185-185)UserInfoResponse(187-187)libs/types/models/TokenResponse.ts (1)
TokenResponse(8-37)proxy/auth/auth.go (1)
UserInfoResponse(19-21)proxy/auth/common.go (1)
TokenData(40-55)
proxy/auth/openshift.go (3)
proxy/auth/common.go (1)
AuthProvider(70-76)libs/types/index.ts (2)
AuthProvider(25-25)OpenShiftProviderSpec(143-143)libs/types/models/OpenShiftProviderSpec.ts (1)
OpenShiftProviderSpec(8-49)
libs/cypress/support/interceptors/fleets.ts (1)
libs/cypress/support/constants.ts (1)
API_VERSION(1-1)
proxy/auth/k8s.go (2)
libs/types/models/AuthProvider.ts (1)
AuthProvider(10-21)libs/types/models/K8sProviderSpec.ts (1)
K8sProviderSpec(10-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: integration-tests
- GitHub Check: Build ocp plugin
- GitHub Check: Build
- GitHub Check: Lint
🔇 Additional comments (20)
libs/types/models/ImageApplicationProviderSpec.ts (1)
10-10: No issues found. This file was properly regenerated from the updated OpenAPI schema.The v1beta1 OpenAPI schema in the flightctl repository contains the updated documentation "Reference to the OCI image or artifact for the application package," and the generated TypeScript file correctly reflects this schema content. This is the expected workflow—the schema was updated, and the file was regenerated accordingly. No manual edits to auto-generated code are apparent.
proxy/go.mod (1)
8-8: Flightctl module bump aligns with API migration; verify build/testsUpdating
github.com/flightctl/flightctlto a newer pseudo‑version is consistent with moving to v1beta1 types. Please confirm the proxy still builds cleanly and the auth/k8s flows pass their tests against this version.libs/ui-components/src/components/AuthProvider/CreateAuthProvider/utils.ts (1)
28-28: AuthProvider now correctly uses the shared API version constantImporting
API_VERSIONand using it for the returnedAuthProvider.apiVersionkeeps created/updated auth providers in sync with the UI’s configured API version, with no behavioural regressions in the surrounding logic.Also applies to: 320-320
libs/cypress/fixtures/repositories/initialRepositories.ts (1)
2-2: Repository fixture correctly switched to the shared Cypress API versionUsing
API_VERSIONforapiVersionin theRepositoryfixture keeps test data aligned with the Cypress‑side version constant and avoids hard‑coded strings.Also applies to: 6-6
libs/cypress/support/interceptors/auth.ts (1)
2-2: Auth interceptor response now uses centralized API versionSwitching the
OrganizationListresponse toapiVersion: API_VERSIONkeeps the mocked organizations in sync with the Cypress API version constant without altering the response structure.Also applies to: 22-22
libs/cypress/fixtures/enrollmentRequests/index.ts (1)
2-2: EnrollmentRequest fixtures consistently reference API_VERSIONAll EnrollmentRequest fixtures now use the shared
API_VERSIONconstant instead of hard‑coded strings, which keeps test data consistent with the configured API version and simplifies future migrations.Also applies to: 26-26, 39-39, 52-52, 65-65
libs/cypress/fixtures/fleets/initialFleets.ts (1)
2-2: Fleet fixtures now use the shared API_VERSION constantBoth Fleet fixtures correctly use
apiVersion: API_VERSION, and the minor trailing‑comma tweak indevicesSummaryis stylistic only and safe.Also applies to: 6-6, 56-56
libs/cypress/support/interceptors/enrollmentRequests.ts (1)
3-3: EnrollmentRequest interceptors correctly aligned with API_VERSIONUsing
API_VERSIONinbuildErResponsekeeps all intercepted EnrollmentRequest list responses consistent with the centralized Cypress API version while preserving the existing response shape and routes.Also applies to: 6-6
libs/cypress/fixtures/auth/organization.ts (1)
1-4: Centralize apiVersion in organization fixtureUsing
API_VERSIONfrom../../support/constantslooks correct and keeps the fixture aligned with future API version bumps without further edits here.libs/cypress/support/interceptors/repositories.ts (1)
3-7: Repositories interceptor now aligned with centralized API_VERSIONImporting
API_VERSIONand wiring it intobuildRepositoriesResponseis consistent with the migration and keeps the list wrapper in sync with the current API version.It’s worth quickly scanning
repoList(inlibs/cypress/fixtures) to ensure individualRepositoryobjects’apiVersionfields, if present, were also migrated toAPI_VERSIONso tests don’t mix v1alpha1/v1beta1 in the same payload.libs/cypress/support/interceptors/devices.ts (1)
2-6: Devices interceptor correctly switched to API_VERSIONImporting
API_VERSIONand using it inbuildDevicesResponsealigns this interceptor with the rest of the suite and keeps the list wrapper consistent with v1beta1.proxy/auth/oidc.go (1)
14-15: OIDC auth handler migrated cleanly to v1beta1 typesSwitching the import to
v1beta1and updatinggetOIDCAuthHandlerto accept*v1beta1.AuthProvider/*v1beta1.OIDCProviderSpeckeeps the handler’s behavior intact while aligning it with the new API version.Also applies to: 37-37
proxy/auth/aap.go (1)
13-15: AAP auth handler now wired to v1beta1 provider/specThe updated import and
getAAPAuthHandlersignature correctly move this flow ontov1beta1.AuthProviderandv1beta1.AapProviderSpecwithout altering behavior.Also applies to: 53-53
proxy/auth/openshift.go (1)
15-16: OpenShift auth handler signature/import updated to v1beta1Using
v1beta1.AuthProviderandv1beta1.OpenShiftProviderSpechere matches the rest of the auth package’s migration and maintains existing behavior around URL/scopes construction.Also applies to: 37-37
proxy/auth/k8s.go (1)
13-15: K8s token auth handler moved to v1beta1 without behavior changeThe updated import and
getK8sAuthHandlersignature using*v1beta1.AuthProvider/*v1beta1.K8sProviderSpecalign this handler with the new API version while preserving the existing behavior of validating tokens via the FlightCtl API.Also applies to: 199-213
libs/cypress/support/interceptors/fleets.ts (1)
3-3: LGTM! Centralized API version management.The import and usage of the
API_VERSIONconstant properly centralizes API version management across the Cypress test suite, making future version updates easier.Also applies to: 6-6
proxy/auth/oauth2.go (1)
10-10: LGTM! API version migration applied correctly.The import and function signature have been updated consistently to use v1beta1 types.
Also applies to: 26-26
proxy/auth/common.go (1)
21-21: LGTM! Consistent API version migration.The import, provider type constants, and function signature have been updated consistently to use v1beta1 types. The provider constants correctly convert v1beta1 enum values to strings.
Also applies to: 27-31, 646-646
proxy/auth/api_client.go (1)
15-15: LGTM! Token API interactions migrated to v1beta1.All function signatures, type declarations, and API interactions have been consistently updated to use v1beta1 types for TokenRequest, TokenResponse, and UserInfoResponse.
Also applies to: 22-22, 71-71, 88-88, 157-157, 170-170, 194-194
proxy/auth/auth.go (1)
12-12: Code migration to v1beta1 is complete and consistent — no issues found.Verification confirms:
- ✓ All remaining v1alpha1 references removed (0 remaining)
- ✓ All 8 proxy/auth files comprehensively updated to v1beta1 (38 v1beta1 references across auth.go, openshift.go, oidc.go, oauth2.go, k8s.go, common.go, api_client.go, aap.go)
- All function signatures, field types, imports, and provider config management consistently use v1beta1 types
The flightctl dependency (
v1.0.0-main.0.20251125075421-bbc6daa7c2e7) is a development snapshot from the main branch. Backend deployment status and specific breaking changes documentation cannot be verified from the codebase alone—these are operational concerns that should be confirmed by deployment and testing teams.
d46b473 to
ad48b93
Compare
API has been moved from v1alpha1 to v1beta1.
Summary by CodeRabbit
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.