Skip to content
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

feat: add additional annotations on storage service #823

Merged
merged 1 commit into from
Mar 27, 2025

Conversation

gfyrag
Copy link
Contributor

@gfyrag gfyrag commented Mar 25, 2025

No description provided.

@gfyrag gfyrag requested a review from a team as a code owner March 25, 2025 16:13
Copy link

coderabbitai bot commented Mar 25, 2025

Walkthrough

The changes integrate service configuration capabilities into both the storage configuration and component instantiation. A new StorageService type is introduced to hold service annotations along with a conversion method. The Storage type is updated to include this new service configuration. Additionally, in the storage component, a new Service struct is added along with changes to the Args struct (including updating the DisableUpgrade field) and modifications to the environment variable generation to use updated service metadata.

Changes

File(s) Change Summary
deployments/pulumi/pkg/config/config.go - Added new type StorageService with an Annotations map field and a toInput() method for conversion.
- Updated Storage type to include a new Service field.
- Modified Storage.toInput() to incorporate service conversion via s.Service.toInput().
deployments/pulumi/pkg/storage/component.go - Introduced a new Service struct with an Annotations field as a pulumix Input.
- Updated Args struct: changed DisableUpgrade from pulumix.Output to pulumix.Input and added a new Service field.
- Modified GetEnvVars to use service metadata for POSTGRES_URI construction.
- Adjusted NewComponent to propagate service annotations and updated handling of DisableUpgrade.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Storage
    participant StorageService
    participant PulumiConverter
    Caller->>Storage: Call toInput()
    Storage->>StorageService: Call toInput() for service config
    StorageService->>PulumiConverter: Convert annotations using pulumix.Val
    PulumiConverter-->>StorageService: Return storage.Service object
    StorageService-->>Storage: Return service input
    Storage-->>Caller: Aggregate and return input including service config
Loading
sequenceDiagram
    participant ComponentCreator
    participant Args
    participant Service
    participant EnvUpdater
    ComponentCreator->>Args: Provide Service annotations & DisableUpgrade (Input)
    Args->>Service: Build service metadata with annotations
    ComponentCreator->>EnvUpdater: Invoke GetEnvVars()
    EnvUpdater->>Service: Retrieve Name and Namespace metadata
    Service-->>EnvUpdater: Return metadata
    EnvUpdater-->>ComponentCreator: Return POSTGRES_URI based on service metadata
Loading

Poem

I'm a rabbit with a code-tuned beat,
Hopping through changes both nimble and sweet.
Service annotations now dance in line,
With storage and components perfectly in time.
In every hop and every byte,
I celebrate deployments that feel 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 1f81235 and 4438cab.

📒 Files selected for processing (2)
  • deployments/pulumi/pkg/config/config.go (3 hunks)
  • deployments/pulumi/pkg/storage/component.go (4 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
deployments/pulumi/pkg/storage/component.go (4)
deployments/pulumi/pkg/storage/setup_postgres.go (1)
  • PostgresDatabaseArgs (12-15)
deployments/pulumi/pkg/storage/setup_rds.go (1)
  • RDSDatabaseArgs (96-101)
deployments/pulumi/pkg/storage/component_external.go (6)
  • cmp (20-22)
  • cmp (24-26)
  • cmp (28-30)
  • cmp (32-34)
  • cmp (36-38)
  • cmp (40-42)
deployments/pulumi/pkg/storage/component_postgres.go (7)
  • cmp (24-26)
  • cmp (28-30)
  • cmp (32-34)
  • cmp (36-42)
  • cmp (44-46)
  • cmp (48-50)
  • cmp (52-54)
deployments/pulumi/pkg/config/config.go (1)
deployments/pulumi/pkg/storage/component.go (1)
  • Service (51-53)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Tests
🔇 Additional comments (8)
deployments/pulumi/pkg/storage/component.go (5)

51-53: New Service struct looks good

This new struct appropriately defines a service with annotations using pulumix.Input[map[string]string] for Kubernetes service configuration.


59-60: Field type change and addition

  1. Changed DisableUpgrade from pulumix.Output[bool] to pulumix.Input[bool] - this provides more flexibility by allowing both static and computed boolean values.
  2. Added new Service field of type Service - integrates the new service configuration capabilities.

These changes align well with Pulumi patterns and enhance the API's flexibility.


117-119: Enhanced service discovery pattern

The environment variable construction now properly uses Kubernetes service discovery pattern by referencing the service's name and namespace from cmp.Service.Metadata, which creates a fully qualified DNS name within the cluster.


305-307: Service annotations integration

The code now correctly incorporates the annotations from the Service configuration into the Kubernetes service metadata, enabling custom annotations to be specified by consumers of the API.


322-322: Updated DisableUpgrade handling

The code now calls ToOutput(ctx.Context()) on args.DisableUpgrade before applying the transformation function, which properly handles the type change from Output[bool] to Input[bool].

deployments/pulumi/pkg/config/config.go (3)

220-229: Well-structured StorageService type with clear conversion method

The new StorageService type is well-designed with:

  1. Clear JSON/YAML field tags for proper serialization
  2. Good documentation comment explaining the purpose of the Annotations field
  3. A clean toInput() method that correctly converts to the corresponding storage.Service type

This approach provides a clean separation between configuration and implementation.


240-242: Service configuration integration

The addition of the Service field to the Storage struct enables service configuration to be specified in configuration files, enhancing flexibility for users.


250-250: Updated toInput conversion

The toInput() method properly includes the service configuration conversion, ensuring that annotations specified in configuration are correctly passed to the storage component.

✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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

codecov bot commented Mar 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.00%. Comparing base (1f81235) to head (4438cab).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #823   +/-   ##
=======================================
  Coverage   82.00%   82.00%           
=======================================
  Files         137      137           
  Lines        7512     7512           
=======================================
  Hits         6160     6160           
  Misses       1036     1036           
  Partials      316      316           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gfyrag gfyrag enabled auto-merge March 25, 2025 16:18
@gfyrag gfyrag added this pull request to the merge queue Mar 26, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 26, 2025
@gfyrag gfyrag added this pull request to the merge queue Mar 27, 2025
Merged via the queue into main with commit c48d6fa Mar 27, 2025
10 checks passed
@gfyrag gfyrag deleted the feat/pulumi-additional-annotations branch March 27, 2025 16:53
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