Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Dav-14
Copy link
Contributor

@Dav-14 Dav-14 commented Mar 7, 2025

  • feat: add ingress label
  • docs: add gateway.ingress.labels settings

@Dav-14 Dav-14 requested a review from a team as a code owner March 7, 2025 09:47
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2025

Walkthrough

The pull request includes updates to both documentation and code. The documentation file has been reformatted for improved readability, with table header adjustments and revised alignment of query parameters. A new setting entry (gateway.ingress.labels) and additional Kafka parameters (saslMechanism and saslSCRAMSHASize) have been introduced. In the code, the createIngress function has been refactored to utilize several new mutator functions (withAnnotations, withLabels, withTls, withIngressClassName, and withIngressRules) that modularize and clarify the logic for constructing Ingress objects, including enhanced error handling.

Changes

File Change Summary
docs/09-Configuration reference/01-Settings.md - Reformatting of table headers and rows for consistent alignment.
- Addition of new setting: gateway.ingress.labels (type: Map).
- Formatting updates for query parameters under Kafka broker URI, with new lines for saslMechanism and saslSCRAMSHASize.
internal/resources/gateways/ingress.go - Introduction of new mutator functions: withAnnotations, withLabels, withTls, withIngressClassName, and withIngressRules.
- Refactoring of createIngress to use these functions, improving modularity and error handling.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller
    participant CI as createIngress
    participant WA as withAnnotations
    participant WL as withLabels
    participant WIC as withIngressClassName
    participant WT as withTls
    participant WR as withIngressRules

    Caller->>CI: call createIngress()
    CI->>WA: apply annotations
    WA-->>CI: return annotations status
    CI->>WL: apply labels
    WL-->>CI: return labels status
    CI->>WIC: apply ingress class name
    WIC-->>CI: return class name status
    CI->>WT: apply TLS settings
    WT-->>CI: return TLS status
    CI->>WR: apply ingress rules
    WR-->>CI: return rules status
    CI-->>Caller: Ingress created/returned
Loading

Poem

I'm a bunny coder hopping through the code,
Tweaking docs and functions in my humble abode.
Tables aligned and mutators in play,
Each line of code makes a sunny day.
With carrots of logic and hops of delight,
We celebrate these changes shining so bright!
🥕🐇 Happy coding, all day and night!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 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.

@Dav-14 Dav-14 force-pushed the feat/add_label_on_ingress_0 branch from 61ea81a to 0a1a3e6 Compare March 7, 2025 10:12
@Dav-14 Dav-14 enabled auto-merge March 7, 2025 10:13
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: 0

🧹 Nitpick comments (5)
internal/resources/gateways/ingress.go (5)

12-25: Good abstraction of annotation handling.

This function nicely encapsulates the logic for setting annotations on an ingress resource. The error handling is appropriate, and initializing an empty map when annotations are nil is a good defensive coding practice.

Consider adding documentation comments to describe the purpose and parameters of this function for better maintainability.


27-41: Well-implemented labels functionality.

The implementation correctly adds support for custom ingress labels while ensuring essential default labels are always present. Error handling is appropriate, and the function follows the same pattern as the annotations handler.

Consider adding documentation for this function. Also, you might want to consider giving user-defined labels precedence over default labels in case of conflicts by merging them in reverse order:

-		labels["app.kubernetes.io/component"] = "gateway"
-		labels["app.kubernetes.io/name"] = stack.Name
-		t.SetLabels(labels)
+		defaultLabels := map[string]string{
+			"app.kubernetes.io/component": "gateway",
+			"app.kubernetes.io/name":      stack.Name,
+		}
+		// Merge default labels with user-defined ones, allowing user labels to override defaults
+		for k, v := range defaultLabels {
+			if _, exists := labels[k]; !exists {
+				labels[k] = v
+			}
+		}
+		t.SetLabels(labels)

43-55: Clean TLS configuration handling.

The function is concise and clearly handles the conditional TLS configuration. The early return pattern when TLS is nil is a good practice.

Consider adding documentation comments to this function to explain its purpose and parameters.


57-75: Good implementation of ingress class name handling with proper precedence logic.

The function correctly handles multiple sources for the ingress class name with proper precedence: gateway spec overrides settings. Error handling is also appropriate.

Consider adding documentation for this function. Also, the extra blank line at line 63 could be removed for consistency.


77-106: Effective encapsulation of ingress rules configuration.

The function clearly defines and sets up the ingress rules for routing traffic to the gateway service.

Consider adding documentation for this function to explain its purpose and explain the routing configuration for future developers.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 61ea81a and 0a1a3e6.

📒 Files selected for processing (2)
  • docs/09-Configuration reference/01-Settings.md (5 hunks)
  • internal/resources/gateways/ingress.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/09-Configuration reference/01-Settings.md
🔇 Additional comments (2)
internal/resources/gateways/ingress.go (2)

9-9: Added import is appropriate for the new functionality.

This import of the client package is necessary to support the client.Object parameter type in the new mutator functions.


108-124: Excellent refactoring of the createIngress function.

The refactored function is much more modular and readable, clearly separating different concerns into focused mutator functions. The order of operations is logical, and the function handles the case where ingress is not defined in the gateway spec.

Please ensure that this implementation is tested thoroughly, especially with various combinations of user-defined and default labels to verify the correct behavior.

@Dav-14 Dav-14 added this pull request to the merge queue Mar 7, 2025
github-merge-queue bot pushed a commit that referenced this pull request Mar 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 7, 2025
@Dav-14 Dav-14 added this pull request to the merge queue Mar 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 7, 2025
@Dav-14 Dav-14 added this pull request to the merge queue Mar 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 7, 2025
@Dav-14 Dav-14 added this pull request to the merge queue Mar 7, 2025
Merged via the queue into main with commit 8dfb8ba Mar 7, 2025
7 checks passed
@Dav-14 Dav-14 deleted the feat/add_label_on_ingress_0 branch March 7, 2025 10:44
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.

4 participants