Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Add default port when undefined #141

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

dominykasn
Copy link
Contributor

@dominykasn dominykasn commented Feb 18, 2025

fixes error if no port is defined in .Values.worker.config and .Values.webhook.config, e.g.

Error: template: n8n/templates/deployment.worker.yaml:71:43: executing "n8n/templates/deployment.worker.yaml" at <.Values.worker.config>: wrong type for value; expected map[string]interface {}; got interface {}

Summary by CodeRabbit

  • Chores
    • Enhanced deployment configurations to safely handle missing settings and ensure robust default behavior.
    • Improved environment variable formatting for consistency and reliability.

@dominykasn dominykasn requested a review from a team as a code owner February 18, 2025 15:29
Copy link

coderabbitai bot commented Feb 18, 2025

Walkthrough

This pull request updates the Helm chart deployment templates for n8n by enhancing the retrieval logic for the container port configuration. In the templates for the webhook, worker, and main deployments, the configuration lookup is now wrapped with a default (dict) function to safely handle cases when the respective config object is undefined. Additionally, a minor formatting tweak was applied to the environment variable declaration in the main deployment template.

Changes

File(s) Change Summary
charts/n8n/templates/deployment.webhook.yaml
charts/n8n/templates/deployment.worker.yaml
charts/n8n/templates/deployment.yaml (containerPort)
Updated the containerPort retrieval expression by wrapping .Values.<component>.config with default (dict), ensuring it defaults to an empty dictionary if unset, with a fallback port value of 5678.
charts/n8n/templates/deployment.yaml (env) Removed an unnecessary trailing space from the environment variable declaration, which improves formatting while preserving the original logic for iterating over .Values.main.extraEnv.

Possibly related PRs

  • Next Gen Chart #132: Modifies container port retrieval logic in deployment configurations similarly to enhance robustness by using a default function.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @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

@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: 0

🧹 Nitpick comments (1)
charts/n8n/templates/deployment.yaml (1)

68-68: Refined Environment Variable Formatting

The minor formatting adjustment for the env declaration on line 68 (ensuring there is no extraneous whitespace) improves readability and consistency. Although it does not change functionality, it contributes to a cleaner template.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d7babc and 79006c5.

📒 Files selected for processing (3)
  • charts/n8n/templates/deployment.webhook.yaml (1 hunks)
  • charts/n8n/templates/deployment.worker.yaml (1 hunks)
  • charts/n8n/templates/deployment.yaml (2 hunks)
🔇 Additional comments (3)
charts/n8n/templates/deployment.worker.yaml (1)

71-71: Enhanced Port Retrieval Fallback in Worker Deployment

The updated container port retrieval now wraps .Values.worker.config in a default (dict) function. This prevents errors in cases where the configuration is undefined and ensures that the "port" key lookup safely defaults to 5678 if not provided.

charts/n8n/templates/deployment.yaml (1)

77-77: Robust Container Port Configuration in Main Deployment

By wrapping .Values.main.config in default (dict), the template safely handles cases where the configuration is missing. This ensures that the port lookup falls back to the specified default (5678) without triggering template errors.

charts/n8n/templates/deployment.webhook.yaml (1)

69-69: Consistent Port Configuration for Webhook Deployment

The change to use {{ get (default (dict) .Values.webhook.config) "port" | default 5678 }} introduces a safety net by defaulting to an empty dictionary if the webhook configuration is undefined. This change aligns the webhook template with the updates made in both the worker and main deployments, ensuring robust and error-free port resolution.

@Vad1mo Vad1mo merged commit bb609e8 into 8gears:main Feb 19, 2025
2 of 3 checks passed
@Vad1mo
Copy link
Member

Vad1mo commented Feb 19, 2025

thank you for your contribution, the whole worker webhook part is not yet complete, hence the pre-release

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants