-
Notifications
You must be signed in to change notification settings - Fork 11
fix: Deployment version channel refactor #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis pull request systematically updates the type definitions and schema references for deployment channels across the codebase. In multiple UI components, API routes, routers, authentication utilities, and database schemas, properties and operations that formerly used Changes
Possibly related PRs
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/auth/src/utils/rbac.ts (1)
125-129: Maintained the "releaseChannel" scope type for compatibility.This is a notable design decision: while the database entity has been renamed to
deploymentVersionChannel, the scope type returned by the function is still "releaseChannel". This approach maintains compatibility with existing RBAC definitions and permission checks that expect the "releaseChannel" scope type.While this approach is pragmatic for a refactoring effort, consider whether a follow-up task to align the scope type name with the entity name would improve long-term code clarity. The scope type is defined in
packages/db/src/schema/rbac.tsas noted in the retrieved learning.packages/api/src/router/deployment.ts (1)
30-73: Maintainability enhancement: Consider updating permission names.While the implementation has been updated to use
deploymentVersionChannel, the permission names (likePermission.ReleaseChannelCreate,Permission.ReleaseChannelUpdate, etc.) still use the old terminology. Consider updating these in a future PR to maintain consistency in terminology throughout the codebase.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (23)
apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/policy-override/UpdateOverride.tsx(1 hunks)apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-policy-drawer/EnvironmentPolicyDrawer.tsx(1 hunks)apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/ReleaseChannels.tsx(1 hunks)apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Overview.tsx(1 hunks)apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-condition/ReleaseConditionDialog.tsx(1 hunks)apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx(1 hunks)apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsx(1 hunks)apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/channel/drawer/Overview.tsx(1 hunks)apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/release/condition/ReleaseConditionDialog.tsx(1 hunks)apps/webservice/src/app/api/v1/deployments/[deploymentId]/release-channels/name/[name]/route.ts(1 hunks)apps/webservice/src/app/api/v1/environments/route.ts(1 hunks)apps/webservice/src/app/api/v1/release-channels/route.ts(3 hunks)packages/api/src/router/deployment-version.ts(2 hunks)packages/api/src/router/deployment.ts(8 hunks)packages/api/src/router/environment-policy.ts(2 hunks)packages/api/src/router/environment.ts(2 hunks)packages/auth/src/utils/rbac.ts(2 hunks)packages/db/src/schema/release-channel-relations.ts(2 hunks)packages/db/src/schema/release-channel.ts(2 hunks)packages/db/src/schema/release.ts(2 hunks)packages/job-dispatch/src/environment-release-channel-update.ts(1 hunks)packages/job-dispatch/src/policies/release-sequencing.ts(1 hunks)packages/job-dispatch/src/policies/release-string-check.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{ts,tsx}`: **Note on Error Handling:** Avoid strict en...
**/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.
apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/channel/drawer/Overview.tsxapps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-policy-drawer/EnvironmentPolicyDrawer.tsxapps/webservice/src/app/api/v1/environments/route.tspackages/job-dispatch/src/policies/release-string-check.tspackages/api/src/router/environment-policy.tspackages/api/src/router/environment.tspackages/job-dispatch/src/environment-release-channel-update.tspackages/job-dispatch/src/policies/release-sequencing.tsapps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsxpackages/db/src/schema/release-channel.tsapps/webservice/src/app/[workspaceSlug]/(appv2)/_components/release/condition/ReleaseConditionDialog.tsxapps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/policy-override/UpdateOverride.tsxapps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/ReleaseChannels.tsxpackages/api/src/router/deployment-version.tspackages/auth/src/utils/rbac.tspackages/db/src/schema/release-channel-relations.tsapps/webservice/src/app/api/v1/release-channels/route.tsapps/webservice/src/app/[workspaceSlug]/(app)/_components/release-condition/ReleaseConditionDialog.tsxapps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Overview.tsxpackages/db/src/schema/release.tsapps/webservice/src/app/api/v1/deployments/[deploymentId]/release-channels/name/[name]/route.tsapps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsxpackages/api/src/router/deployment.ts
🧠 Learnings (3)
apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-policy-drawer/EnvironmentPolicyDrawer.tsx (2)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#183
File: apps/webservice/src/app/[workspaceSlug]/_components/environment-drawer/ReleaseChannels.tsx:48-71
Timestamp: 2025-03-12T21:38:05.695Z
Learning: Prefer using `Object.fromEntries` over `.reduce` for transforming arrays into objects in React components to improve readability and maintainability.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2025-03-12T21:38:05.695Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsx (2)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#183
File: apps/webservice/src/app/[workspaceSlug]/_components/environment-drawer/ReleaseChannels.tsx:48-71
Timestamp: 2025-03-12T21:38:05.695Z
Learning: Prefer using `Object.fromEntries` over `.reduce` for transforming arrays into objects in React components to improve readability and maintainability.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2025-03-12T21:38:05.695Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
packages/auth/src/utils/rbac.ts (1)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/auth/src/utils/rbac.ts:102-118
Timestamp: 2025-03-12T21:38:05.696Z
Learning: The `releaseChannel` scope type is included in the `scopeType` enum in `packages/db/src/schema/rbac.ts`.
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Typecheck
- GitHub Check: Lint
- GitHub Check: build (linux/amd64)
- GitHub Check: build (linux/amd64)
- GitHub Check: build (linux/amd64)
- GitHub Check: build (linux/amd64)
🔇 Additional comments (47)
packages/job-dispatch/src/policies/release-sequencing.ts (1)
94-94: Schema refactoring looks goodThe changes correctly update references from
schema.releaseChanneltoschema.deploymentVersionChannelconsistently throughout the query. This aligns with the overall transition from ReleaseChannel to DeploymentVersionChannel in the database schema.Also applies to: 98-98, 101-101
packages/job-dispatch/src/policies/release-string-check.ts (1)
24-25: Schema update properly implementedThe refactoring from
schema.releaseChanneltoschema.deploymentVersionChannelhas been consistently applied to all relevant fields and join conditions. The modifications maintain the original query functionality while using the new schema.Also applies to: 29-29, 32-32
apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/release/condition/ReleaseConditionDialog.tsx (1)
46-46: Type signature updated correctlyThe type for
releaseChannelshas been properly updated fromSCHEMA.ReleaseChannel[]toSCHEMA.DeploymentVersionChannel[], maintaining type safety with the new schema structure.apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/channel/drawer/Overview.tsx (1)
41-41: Type definition properly updatedThe
releaseChannelprop type has been correctly changed fromSCHEMA.ReleaseChanneltoSCHEMA.DeploymentVersionChannel, aligning with the schema changes throughout the codebase.packages/job-dispatch/src/environment-release-channel-update.ts (1)
20-28: Schema reference successfully updated in getReleaseFilter functionThe schema reference has been properly updated from
SCHEMA.releaseChanneltoSCHEMA.deploymentVersionChannelin both the table selection and where condition. This change maintains the function's behavior while aligning with the broader refactoring from release channels to deployment version channels across the codebase.apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Overview.tsx (1)
40-42: Type definition correctly updatedThe type of
releaseChannelinOverviewPropshas been properly updated fromSCHEMA.ReleaseChanneltoSCHEMA.DeploymentVersionChannel, ensuring type consistency across the component. Since the component continues to use the same properties of the channel object, this change maintains functionality while updating to the new schema reference.apps/webservice/src/app/api/v1/environments/route.ts (1)
53-62: Database query properly updated to use deployment version channelThe database query has been correctly modified to select from
schema.deploymentVersionChannelinstead ofschema.releaseChannel, and the where clause has been updated accordingly. The mapping logic to extract channel and deployment IDs remains unchanged, preserving the function's behavior while updating the schema reference.apps/webservice/src/app/api/v1/deployments/[deploymentId]/release-channels/name/[name]/route.ts (1)
22-32: DELETE operation updated to target the correct schemaThe delete operation has been properly updated to target
schema.deploymentVersionChannelinstead ofschema.releaseChannel, with corresponding updates to the where clause conditions. The error handling remains unchanged, ensuring that the API endpoint continues to function as expected with the new schema reference.apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx (1)
178-178: Type update appears correct.The type change from
schema.ReleaseChannel | nulltoschema.DeploymentVersionChannel | nullaligns with the broader refactoring in this PR. The component usage of this property remains consistent.apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/policy-override/UpdateOverride.tsx (1)
13-13: Type update appears correct.The change from
SCHEMA.ReleaseChannel[]toSCHEMA.DeploymentVersionChannel[]is consistent with the deployment version channel refactoring throughout the codebase.packages/api/src/router/environment-policy.ts (2)
17-17: Import updated correctly.Updated import from
releaseChanneltodeploymentVersionChannelaligns with the schema refactoring.
40-44: Database join condition updated correctly.The left join operation has been updated to use
deploymentVersionChannelinstead ofreleaseChannel, maintaining the same join condition structure. This change ensures database queries properly reference the new schema entity.apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/ReleaseChannels.tsx (2)
17-17: Type update appears correct.The change from
SCHEMA.ReleaseChannel[]toSCHEMA.DeploymentVersionChannel[]aligns with the refactoring pattern in this PR.
20-20: Type update appears correct.The
Policytype'sreleaseChannelsproperty has been updated to useSCHEMA.DeploymentVersionChannel[]to maintain consistency with the other type changes.apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsx (1)
18-18: Type definition updated correctly to use DeploymentVersionChannel.The type definition has been updated to use the new
DeploymentVersionChannelschema type instead of the previousReleaseChanneltype. This change is consistent with the deployment version channel refactoring mentioned in the PR objectives.packages/api/src/router/deployment-version.ts (2)
257-262: Schema references updated correctly in the policyRCSubquery.The schema references have been properly updated from
SCHEMA.releaseChanneltoSCHEMA.deploymentVersionChannelin the select statement of the policyRCSubquery. This maintains consistency with the deployment version channel refactoring.
592-596: Join condition updated correctly to reference the new schema.The inner join condition has been properly updated to reference
SCHEMA.deploymentVersionChannelinstead of the previousSCHEMA.releaseChannel. This ensures that the query continues to function correctly with the refactored schema.apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-condition/ReleaseConditionDialog.tsx (1)
46-46: Type definition updated correctly for releaseChannels prop.The type definition for the
releaseChannelsprop has been updated fromSCHEMA.ReleaseChannel[]toSCHEMA.DeploymentVersionChannel[], maintaining consistency with the deployment version channel refactoring across the codebase.apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-policy-drawer/EnvironmentPolicyDrawer.tsx (1)
119-119: ViewProps type updated correctly to use DeploymentVersionChannel.The
releaseChannelsproperty in theViewPropstype has been properly updated to useSCHEMA.DeploymentVersionChannel[]instead of the previousSCHEMA.ReleaseChannel[]. This change aligns with the deployment version channel refactoring efforts across the codebase.packages/api/src/router/environment.ts (3)
19-19: Import updated to use deploymentVersionChannel.The import has been updated to include
deploymentVersionChannelwhich aligns with the broader refactoring effort across the codebase.
61-66: Field references updated to use deploymentVersionChannel.The field references in the subquery selection have been systematically updated from
releaseChannel*to reference the corresponding fields fromdeploymentVersionChannel. This is consistent with the deployment version channel refactoring.
69-74: Join condition updated to use deploymentVersionChannel.The inner join condition has been properly updated to join on
deploymentVersionChannelinstead ofreleaseChannel, maintaining the same relationship structure but with the renamed entity.packages/db/src/schema/release-channel-relations.ts (3)
5-5: Import updated to deploymentVersionChannel.The import statement has been correctly updated to import
deploymentVersionChannelinstead ofreleaseChannel.
7-12: releaseChannelRelations updated to use deploymentVersionChannel.The
releaseChannelRelationsfunction now correctly usesdeploymentVersionChannelas its base entity while maintaining the same relationship structure.
21-24: Relation references updated to deploymentVersionChannel.The relation definition for
releaseChannelwithinenvironmentPolicyReleaseChannelRelationshas been updated to reference thedeploymentVersionChannelentity and its ID field, maintaining database integrity.packages/db/src/schema/release-channel.ts (2)
6-6: Import updated to deploymentVersionChannel.The import statement has been correctly updated to import
deploymentVersionChannelinstead ofreleaseChannel.
16-17: Foreign key reference updated to deploymentVersionChannel.id.The foreign key reference for the
channelIdfield has been correctly updated to referencedeploymentVersionChannel.id, ensuring proper database relationships.packages/auth/src/utils/rbac.ts (2)
16-16: Added deploymentVersionChannel to imports.The import statement has been updated to include
deploymentVersionChannel, aligning with the broader refactoring.
118-123: Updated inner join to use deploymentVersionChannel.The inner join in
getReleaseChannelScopesfunction has been updated to usedeploymentVersionChannelinstead ofreleaseChannel, maintaining the same query structure with the renamed entity.apps/webservice/src/app/api/v1/release-channels/route.ts (6)
5-5: Import updated to match the renamed schema entity.The import statement has been correctly updated to use
createDeploymentVersionChannelinstead ofcreateReleaseChannel, aligning with the schema changes.
15-15: Middleware updated to use the new schema validator.The
parseBodymiddleware now correctly uses thecreateDeploymentVersionChannelvalidator to match the schema changes.
23-23: Type inference correctly updated.The handler's type definition has been updated to use the new schema type, maintaining type safety throughout the request handling chain.
27-32: Database query updated to use new schema table.The database query has been updated consistently to use
SCHEMA.deploymentVersionChannelinstead ofSCHEMA.releaseChannelin both the table reference and field selectors.
43-43: Insert operation updated to target the new schema table.The database insert operation now correctly targets
SCHEMA.deploymentVersionChannel.
36-48: Note: API response message remains backward compatible.While the database schema has been updated, the error message in the API response still mentions "Release channel already exists". This preserves backward compatibility for API consumers while the internal implementation has changed.
packages/db/src/schema/release.ts (2)
55-69: Schema table definition renamed to match new terminology.The table definition has been appropriately renamed to
deploymentVersionChannelwhile keeping the underlying database table namedeployment_version_channelunchanged, which avoids the need for database migrations.
71-79: Type definitions and schema functions updated consistently.All related type definitions and schema functions have been updated:
ReleaseChannel→DeploymentVersionChannelcreateReleaseChannel→createDeploymentVersionChannelupdateReleaseChannel→updateDeploymentVersionChannelThe changes maintain the same structure and validation rules, ensuring functionality remains the same.
packages/api/src/router/deployment.ts (10)
32-32: Input schema updated to use new validation schema.The input validation for the create procedure now uses
SCHEMA.createDeploymentVersionChannelinstead ofSCHEMA.createReleaseChannel.
41-41: Insert operation updated for new schema table.The database insert operation now correctly uses
SCHEMA.deploymentVersionChannel.
46-49: Updated input schema for update procedure.The input schema for the update procedure now correctly uses
SCHEMA.updateDeploymentVersionChannelwhile maintaining the same structure.
59-62: Update operation modified to use new schema table.Both the table reference and the where condition have been updated to use
SCHEMA.deploymentVersionChannel.
75-76: Delete operation updated to target new schema table.The delete operation now correctly targets
SCHEMA.deploymentVersionChannelwith an updated where condition.
91-92: List query updated to use new schema table.The select operation and where clause in the list query now correctly reference
SCHEMA.deploymentVersionChannel.
122-124: Query method updated to use new schema entity.The query method has been updated to use
deploymentVersionChannelinstead ofreleaseChannel.
536-541: Left join updated to use new schema table.The left join operation in the bySlug query now correctly uses
SCHEMA.deploymentVersionChannel.
576-581: Consistent update to all join operations.The left join in the bySystemId query has also been updated to use
SCHEMA.deploymentVersionChannel, ensuring consistency throughout the codebase.
557-558: API response structure remains backward compatible.The property name in the returned object is still
releaseChannelseven though it now containsdeployment_version_channelobjects. This maintains backward compatibility for API consumers, which is a good practice when refactoring internal implementations.
Summary by CodeRabbit
Refactor
Chore
These updates enhance system reliability and set the stage for future improvements without altering end-user functionality.