Skip to content

feat: configure env version rollout cli#34

Merged
adityachoudhari26 merged 3 commits intomainfrom
configure-env-version-rollout-cli
Jun 25, 2025
Merged

feat: configure env version rollout cli#34
adityachoudhari26 merged 3 commits intomainfrom
configure-env-version-rollout-cli

Conversation

@adityachoudhari26
Copy link
Member

@adityachoudhari26 adityachoudhari26 commented Jun 25, 2025

Summary by CodeRabbit

  • New Features

    • Added support for configuring environment version rollout strategies in policy creation and updates.
    • Introduced the ability to approve or reject deployment versions for specific environments.
    • Enabled locking and unlocking of release targets to control deployment flows.
    • Added new policy parameters, including rollout types and maximum retries.
  • Enhancements

    • Extended policy configuration options to support advanced rollout and deployment controls.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 25, 2025

Walkthrough

This update introduces support for environment version rollout strategies in policy management. It adds new data structures, API client methods, and CLI flag handling to enable specifying rollout parameters when creating or updating policies. Additionally, the API client gains methods for environment-specific deployment version approvals/rejections and release target locking, with corresponding request/response types.

Changes

File(s) Change Summary
cmd/ctrlc/root/api/upsert/policy/policy.go Added parseEnvironmentVersionRollout function to parse rollout JSON, integrated new --environment-version-rollout CLI flag, and extended policy creation to include parsed rollout struct.
cmd/ctrlc/root/apply/policy.go Updated createPolicyRequestBody to support optional EnvironmentVersionRollout field, mapping it to the API struct if present.
cmd/ctrlc/root/apply/types.go Added EnvironmentVersionRollout struct and optional pointer field to Policy struct, defining rollout parameters.
internal/api/client.gen.go Introduced new rollout, approval/rejection, and release target lock data models; added API client methods for environment-scoped deployment version approval/rejection and release target locking/unlocking; updated request/response handling and type definitions accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant API Client
    participant Server

    User->>CLI: upsert-policy --environment-version-rollout '{...}'
    CLI->>CLI: parseEnvironmentVersionRollout(JSON)
    CLI->>API Client: UpsertPolicy(EnvironmentVersionRollout)
    API Client->>Server: POST /v1/policies (with rollout params)
    Server-->>API Client: Policy upsert response
    API Client-->>CLI: Response
    CLI-->>User: Display result
Loading
sequenceDiagram
    participant User
    participant CLI
    participant API Client
    participant Server

    User->>CLI: apply policy (with EnvironmentVersionRollout)
    CLI->>API Client: UpsertPolicy(EnvironmentVersionRollout)
    API Client->>Server: POST /v1/policies (with rollout params)
    Server-->>API Client: Response
    API Client-->>CLI: Result
    CLI-->>User: Output
Loading
sequenceDiagram
    participant User
    participant API Client
    participant Server

    User->>API Client: ApproveDeploymentVersionForEnvironment
    API Client->>Server: POST /v1/deployment-versions/{id}/environments/{id}/approve
    Server-->>API Client: Approval response

    User->>API Client: LockReleaseTarget
    API Client->>Server: POST /v1/release-targets/{id}/lock
    Server-->>API Client: Lock response
Loading

Poem

In the warren of code, new rollouts appear,
With flags and with structs, the logic is clear.
Approvals and locks, now handled with care,
Policies hopping with features to share.
From JSON to server, the rabbits delight—
New rollouts are coming, and all works just right!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57bdd6b and a0fb989.

📒 Files selected for processing (1)
  • cmd/ctrlc/root/api/upsert/policy/policy.go (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/ctrlc/root/api/upsert/policy/policy.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: docker (linux/amd64)
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ea81aa and 57bdd6b.

📒 Files selected for processing (4)
  • cmd/ctrlc/root/api/upsert/policy/policy.go (5 hunks)
  • cmd/ctrlc/root/apply/policy.go (2 hunks)
  • cmd/ctrlc/root/apply/types.go (2 hunks)
  • internal/api/client.gen.go (36 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
cmd/ctrlc/root/apply/types.go (1)
internal/api/client.gen.go (1)
  • EnvironmentVersionRollout (348-357)
cmd/ctrlc/root/api/upsert/policy/policy.go (2)
internal/api/client.gen.go (3)
  • InsertEnvironmentVersionRollout (383-392)
  • InsertEnvironmentVersionRolloutRolloutType (395-395)
  • EnvironmentVersionRollout (348-357)
cmd/ctrlc/root/apply/types.go (1)
  • EnvironmentVersionRollout (166-170)
internal/api/client.gen.go (1)
cmd/ctrlc/root/apply/types.go (6)
  • DeploymentVersionSelector (147-151)
  • EnvironmentVersionRollout (166-170)
  • PolicyTarget (135-139)
  • VersionAnyApproval (153-155)
  • VersionRoleApproval (161-164)
  • VersionUserApproval (157-159)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: docker (linux/amd64)
🔇 Additional comments (8)
cmd/ctrlc/root/apply/types.go (1)

132-132: LGTM! Well-structured type definitions.

The addition of the EnvironmentVersionRollout field to the Policy struct and the new struct definition follow Go conventions correctly, with optional fields using pointers and required fields using concrete types.

Also applies to: 166-170

cmd/ctrlc/root/apply/policy.go (1)

122-135: LGTM! Proper type conversion logic.

The conversion from internal EnvironmentVersionRollout to API InsertEnvironmentVersionRollout is handled correctly, with proper nil checking for optional fields and appropriate type casting for the enum type.

Also applies to: 150-150

internal/api/client.gen.go (6)

39-52: Rollout type constants look good.

The duplicate constants for EnvironmentVersionRolloutRolloutType and InsertEnvironmentVersionRolloutRolloutType follow the established pattern for generated API clients, maintaining type safety between read and write operations.


97-97: Status additions are consistent.

The addition of "rejected" status to deployment and release types, along with the EnvironmentId field in ApprovalRecord, properly supports the new environment-specific approval/rejection functionality.

Also applies to: 105-105, 113-113, 121-121, 129-129


382-396: InsertEnvironmentVersionRollout struct is well-structured.

The struct properly defines rollout configuration with clear documentation, appropriate use of pointers for optional fields, and correct JSON tags.


472-474: MaxRetries field implementation is correct.

The use of non-pointer MaxRetries in the Policy struct (line 488) and pointer *MaxRetries in request bodies (lines 983, 1005) correctly distinguishes between required response fields and optional request fields.

Also applies to: 488-488, 983-983, 1005-1005


615-627: ReleaseTargetLockRecord struct properly models lock state.

The struct correctly tracks lock information with appropriate use of timestamps and an optional UnlockedAt field for active locks.


872-887: API client methods are properly implemented.

All new client methods, request builders, response types, and parsers follow the established patterns in the generated code. The implementation correctly handles:

  • Environment-specific deployment version approvals/rejections
  • Release target locking/unlocking
  • Proper HTTP methods and URL construction
  • Comprehensive error response handling

Also applies to: 1175-1183, 2450-2467, 2574-2582, 2801-2883, 3353-3387, 4077-4272, 5333-5434, 6637-6654, 6761-6769, 7031-7158, 7956-8049, 8961-9020, 9361-9387, 9974-10183, 11366-11513

cmd.Flags().StringVar(&resourceTargetSelector, "resource-selector", "", "JSON string for resource target selector")
cmd.Flags().IntVarP(&concurrency, "concurrency", "c", 0, "Concurrency of the policy")
cmd.Flags().StringVar(&deploymentVersionSelector, "version-selector", "", "JSON string for version selector")
cmd.Flags().StringVar(&environmentVersionRollout, "environment-version-rollout", "", "JSON string for environment version rollout")
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add usage example for the new CLI flag.

The new --environment-version-rollout flag lacks documentation and examples, making it difficult for users to understand the expected JSON format.

Consider adding an example to the command's usage documentation around lines 75-90:

 			# Upsert a policy with version approvals
 			$ ctrlc api upsert policy --name my-policy --version-any-approvals '{"requiredApprovalsCount": 2}' --version-user-approvals '[{"userId": "user1"}, {"userId": "user2"}]' --version-role-approvals '[{"roleId": "role1", "requiredApprovalsCount": 1}]'
+
+			# Upsert a policy with environment version rollout
+			$ ctrlc api upsert policy --name my-policy --environment-version-rollout '{"timeScaleInterval": 300.0, "rolloutType": "linear", "positionGrowthFactor": 1.5}'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cmd.Flags().StringVar(&environmentVersionRollout, "environment-version-rollout", "", "JSON string for environment version rollout")
# Upsert a policy with version approvals
$ ctrlc api upsert policy --name my-policy --version-any-approvals '{"requiredApprovalsCount": 2}' --version-user-approvals '[{"userId": "user1"}, {"userId": "user2"}]' --version-role-approvals '[{"roleId": "role1", "requiredApprovalsCount": 1}]'
# Upsert a policy with environment version rollout
$ ctrlc api upsert policy --name my-policy --environment-version-rollout '{"timeScaleInterval": 300.0, "rolloutType": "linear", "positionGrowthFactor": 1.5}'
🤖 Prompt for AI Agents
In cmd/ctrlc/root/api/upsert/policy/policy.go around lines 75 to 90, add a usage
example for the new --environment-version-rollout CLI flag in the command's
usage documentation. Include a clear example JSON string showing the expected
format to help users understand how to use this flag correctly.

@adityachoudhari26 adityachoudhari26 merged commit ac10cff into main Jun 25, 2025
2 checks passed
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