-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add labels on ingress #243
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
Conversation
Dav-14
commented
Mar 7, 2025
- feat: add ingress label
- docs: add gateway.ingress.labels settings
WalkthroughThe 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 ( Changes
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
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
61ea81a to
0a1a3e6
Compare
There was a problem hiding this 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
📒 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.
feat: add labels on ingress