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 support for extra objects #136

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sebastiansterk
Copy link
Contributor

@sebastiansterk sebastiansterk commented Feb 10, 2025

Extra objects

You can add extra objects to the deployment, like configmaps, secrets, etc. by adding them to the extraObjects section in the values.yaml file so no additional deployment/pipeline is needed.

Example:

# values.yaml
extraObjects:
  - apiVersion: v1
    kind: ConfigMap
    metadata:
      name: my-configmap
    data:
      key: value
  - apiVersion: v1
    kind: Secret
    metadata:
      name: my-secret
    data:
      key: value

This is not limited to configmaps or secrets, but supports all resources/kinds within your k8s cluster.

Summary by CodeRabbit

  • New Features
    • Added an option to include additional Kubernetes objects, offering more flexible deployment configurations.
    • Enhanced templating allows dynamic generation of extra configuration objects.
  • Documentation
    • Updated documentation now includes a warning about the upcoming chart redesign and a call for contributor support.
    • A new section provides clear examples for configuring extra objects.
  • Release Updates
    • Chart version updated to 0.26.0.

@sebastiansterk sebastiansterk requested a review from a team as a code owner February 10, 2025 21:45
Copy link

coderabbitai bot commented Feb 10, 2025

Warning

Rate limit exceeded

@sebastiansterk has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 502020f and 1c256a5.

📒 Files selected for processing (1)
  • charts/n8n/values.yaml (1 hunks)

Walkthrough

This pull request updates the n8n Helm chart by adding new documentation and templating support for deploying additional Kubernetes objects. A warning and a new “Extra objects” section with an example have been added to the README. In parallel, a new configuration option (extraObjects) is introduced in the values file, and corresponding templating logic in the extra objects YAML file processes these objects using a new helper function (n8n.render) that is added to the helpers template. Additionally, the chart version is updated from 0.25.2 to 0.26.0.

Changes

File/s Change Summary
README.md Added a warning about the chart redesign and a new “Extra objects” section with an example for including extra Kubernetes objects.
charts/n8n/values.yaml, charts/n8n/.../extra.objects.yaml Introduced a new extraObjects configuration option and added templating logic (range loop and inclusion of rendered YAML) to dynamically generate additional objects.
charts/n8n/.../_helpers.tpl Added a new helper function n8n.render that renders values with context, performing empty checks and converting non-string values to YAML before templating.
charts/n8n/Chart.yaml Updated the Helm chart version from 0.25.2 to 0.26.0.

Sequence Diagram(s)

sequenceDiagram
    participant U as User Values Input
    participant H as Helm Templating Engine
    participant R as n8n.render Helper
    participant K as Kubernetes API

    U->>H: Provide extraObjects in values.yaml
    H->>R: Invoke n8n.render for each extra object
    R-->>H: Return rendered YAML object
    H->>K: Deploy generated Kubernetes objects
Loading

Possibly related PRs

  • Update README.md #118: Includes similar modifications to the README.md with new sections and versioning updates.
  • Update README.md #130: Involves changes to the README.md emphasizing a warning about chart redesign and community involvement.

Suggested reviewers

  • Vad1mo

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: 1

🧹 Nitpick comments (4)
charts/n8n/templates/tests/extra.yaml (1)

1-14: Enhance test coverage with more examples.

While the current examples demonstrate basic usage, consider adding:

  1. A Secret example to demonstrate sensitive data handling
  2. An example with more complex templating
  3. An example using nested objects

Also, add a newline at the end of the file to fix the YAML lint warning.

       name: "templated"
     data:
-      something: {{ printf "templated" }}
+      something: {{ printf "templated" }}
+
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 14-14: no new line character at the end of file

(new-line-at-end-of-file)

charts/n8n/values.yaml (1)

335-338: Enhance documentation with inline example.

While the description references the test example, it would be helpful to include a commented example directly in the values file.

Add an inline example:

 # Example can be found in charts/n8n/templates/tests/extra.yaml
 extraObjects: []
+# Example:
+# extraObjects:
+#   - apiVersion: v1
+#     kind: ConfigMap
+#     metadata:
+#       name: example-config
+#     data:
+#       key: value
README.md (2)

316-318: Clarify the new "Extra Objects" feature documentation.
The new section clearly outlines how to add additional Kubernetes resources via the extraObjects section in values.yaml. For enhanced clarity, consider including a brief note on supported resource types and any limitations or prerequisites (for example, if there are any encoding requirements for Secret data).


319-335: Verify accuracy of the YAML snippet for Kubernetes Secrets.
The example YAML snippet properly demonstrates adding extra objects. However, note that Kubernetes expects Secret data to be base64 encoded when provided under the data field. If the intention is to allow plain text values, consider using stringData or add an inline comment explaining the expected format.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c86470c and dca5981.

📒 Files selected for processing (5)
  • README.md (1 hunks)
  • charts/n8n/templates/_helpers.tpl (1 hunks)
  • charts/n8n/templates/extra.objects.yaml (1 hunks)
  • charts/n8n/templates/tests/extra.yaml (1 hunks)
  • charts/n8n/values.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
charts/n8n/templates/extra.objects.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/tests/extra.yaml

[error] 14-14: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (1)
charts/n8n/templates/extra.objects.yaml (1)

1-4: LGTM! Clean and efficient implementation.

The implementation correctly:

  • Iterates over extraObjects
  • Separates each object with YAML document separator
  • Passes required context to the render function
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/_helpers.tpl Outdated Show resolved Hide resolved
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: 1

🧹 Nitpick comments (1)
charts/n8n/templates/_helpers.tpl (1)

143-144: Add comprehensive documentation.

The current comment lacks important details. Consider adding:

  • Parameter descriptions
  • Return value description
  • Usage examples
  • Security considerations

Add this documentation:

 {{/*
-Renders a complete tree, even values that contains template.
+Renders a complete tree of values, supporting both string and non-string values that contain templates.
+
+Parameters:
+  - value: The value to render. Can be a string containing templates or a complex object.
+  - context: The context object containing variables for template rendering.
+
+Returns:
+  The rendered value as a string.
+
+Example:
+  {{- $value := dict "name" "{{ .Release.Name }}-config" "data" (dict "key" "value") -}}
+  {{- include "n8n.render" (dict "value" $value "context" .) -}}
+
+Security Note:
+  This function executes templates with full access to the context.
+  Ensure that the input values are trusted and properly validated.
 */}}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dca5981 and 267e5cf.

📒 Files selected for processing (1)
  • charts/n8n/templates/_helpers.tpl (1 hunks)
🔇 Additional comments (1)
charts/n8n/templates/_helpers.tpl (1)

145-150: LGTM! Input validation implemented as suggested.

The validation for empty values and context has been implemented as suggested in the past review comments.

charts/n8n/templates/_helpers.tpl Show resolved Hide resolved
Copy link
Member

@Vad1mo Vad1mo left a comment

Choose a reason for hiding this comment

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

I am primary focusing on the next (there is branch with that name) release.

Take a look into it, and see if a PR against that branch makes sense.
Extra objects are already supported. If you didn't spot it, then we need to update the docs to make it more clear. Happy to get
Second opinion on this.

Even if Next is not yet released as webhooks and workers are missing, it is already in prod and working as expected.

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