Skip to content

feat: add gateway ingress tls setting#295

Merged
gfyrag merged 2 commits into
mainfrom
feat/add-gateway-ingress-tls-setting
Jul 1, 2025
Merged

feat: add gateway ingress tls setting#295
gfyrag merged 2 commits into
mainfrom
feat/add-gateway-ingress-tls-setting

Conversation

@gfyrag

@gfyrag gfyrag commented Jul 1, 2025

Copy link
Copy Markdown
Contributor
  • feat: add capability to explicitely enable tls at gateway level
  • feat: add doc

@gfyrag
gfyrag requested a review from a team as a code owner July 1, 2025 08:53
@coderabbitai

coderabbitai Bot commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The documentation was updated to improve table formatting and add a new gateway.ingress.tls.enabled setting. In the code, the withTls function now accepts a context parameter and includes logic to enable TLS based on the new setting, using a default secret name if not specified. Related function calls were updated accordingly.

Changes

File(s) Change Summary
docs/09-Configuration reference/01-Settings.md Improved table formatting and documented new gateway.ingress.tls.enabled setting.
internal/resources/gateways/ingress.go Updated withTls to accept context, added logic for TLS enablement based on new setting, and updated related function calls.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Gateway
    participant Settings
    participant Ingress

    User->>Gateway: Create or update Gateway
    Gateway->>withTls: Call with context and Gateway object
    withTls->>Settings: Check "gateway.ingress.tls.enabled"
    alt TLS explicitly configured
        withTls->>Ingress: Set TLS using provided secret name
    else TLS enabled via setting
        withTls->>Ingress: Set TLS with default secret name
    else TLS not enabled
        withTls-->>Ingress: Do not set TLS
    end
Loading

Suggested reviewers

  • paul-nicolas

Poem

In the warren of code, a new setting appears,
TLS now toggled, allaying old fears.
Docs polished neat, a table refined,
Secret names conjured if none are defined.
With context in tow, our ingress is bright—
A rabbit’s delight in secure, gentle light! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch feat/add-gateway-ingress-tls-setting

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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests 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.

@cursor

cursor Bot commented Jul 1, 2025

Copy link
Copy Markdown

🚨 BugBot couldn't run

BugBot is experiencing high demand right now. Try again in a few minutes by commenting "bugbot run" (requestId: serverGenReqId_7f560a54-6739-41d6-832c-641b68b39a9a).

@gfyrag
gfyrag enabled auto-merge July 1, 2025 08:57

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f838ee and e728d3e.

📒 Files selected for processing (2)
  • docs/09-Configuration reference/01-Settings.md (2 hunks)
  • internal/resources/gateways/ingress.go (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/resources/gateways/ingress.go (5)
internal/core/context.go (1)
  • Context (10-16)
api/formance.com/v1beta1/gateway_types.go (1)
  • Gateway (76-82)
internal/core/utils.go (1)
  • ObjectMutator (70-70)
internal/resources/settings/helpers.go (1)
  • GetBoolOrFalse (242-244)
api/formance.com/v1beta1/stack_types.go (1)
  • Stack (77-83)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Tests
🔇 Additional comments (6)
docs/09-Configuration reference/01-Settings.md (2)

12-12: Minor table formatting improvement.

The table separator formatting has been made more compact and consistent.


57-57: New TLS setting documentation looks accurate.

The new gateway.ingress.tls.enabled setting is properly documented with correct type, example, and clear description that aligns with the implementation in the Go code.

internal/resources/gateways/ingress.go (4)

50-50: Function signature updated to support configuration-based TLS enablement.

The addition of the ctx core.Context parameter enables the function to access configuration settings, which is necessary for the new TLS enablement feature.


54-60: Good error handling and configuration retrieval.

The implementation properly:

  • Uses GetBoolOrFalse which provides a safe default of false
  • Handles errors from the settings retrieval
  • Only enables TLS when explicitly configured via settings

141-141: Function call correctly updated with context parameter.

The call to withTls has been properly updated to pass the required context parameter.


66-69: No outdated withTls calls found

I verified that all invocations of withTls use the updated signature (withTls(ctx, gateway)). No calls with a single-parameter signature exist in the codebase.

Comment on lines +52 to 64
var secretName string
if gateway.Spec.Ingress.TLS == nil {
return nil
tlsEnabled, err := settings.GetBoolOrFalse(ctx, gateway.Spec.Stack, "gateway", "ingress", "tls", "enabled")
if err != nil {
return err
}
if !tlsEnabled {
return nil
}
secretName = gateway.Name + "-tls"
} else {
secretName = gateway.Spec.Ingress.TLS.SecretName
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify that default TLS secret will be available.

The new logic correctly implements configuration-based TLS enablement, but when TLS is enabled via settings, it generates a default secret name (gateway.Name + "-tls"). This assumes the secret will exist or be created by another process.

Please verify that the default TLS secret generation and management is handled properly:


🏁 Script executed:

#!/bin/bash
# Description: Check if there's any secret management logic for the default TLS secret name pattern

# Search for TLS secret creation or management logic
rg -A 5 -B 5 "tls.*secret|secret.*tls" --type go

# Search for specific pattern of default secret name generation
rg "\-tls" --type go

# Look for certificate or TLS secret management
ast-grep --pattern 'func $FUNC($_) {
  $$$
  SecretName: $_,
  $$$
}'

Length of output: 3571


Ensure default TLS secret is provisioned or created

The code now derives secretName = gateway.Name + "-tls" when TLS is enabled via settings, but there’s no logic in this package to actually create or validate that Kubernetes Secret. Without it, the Ingress will reference a non-existent secret and fail.

Please address this by either:

  • Adding Secret creation logic (e.g. a v1.Secret manifest or integration with cert-manager) alongside the Ingress.
  • Or documenting clearly that users must provision a Secret named <gateway.Name>-tls before enabling TLS.

Location to update:
• internal/resources/gateways/ingress.go (around lines 52–64)

🤖 Prompt for AI Agents
In internal/resources/gateways/ingress.go around lines 52 to 64, the code sets
secretName to gateway.Name + "-tls" when TLS is enabled via settings but does
not create or validate the corresponding Kubernetes Secret. To fix this, add
logic to create or ensure the existence of the TLS Secret (for example, by
generating a v1.Secret manifest or integrating with cert-manager) before
referencing it in the Ingress, or alternatively add clear documentation stating
that users must manually provision a Secret named <gateway.Name>-tls prior to
enabling TLS.

@gfyrag
gfyrag added this pull request to the merge queue Jul 1, 2025
Merged via the queue into main with commit d73b78d Jul 1, 2025
11 of 12 checks passed
@gfyrag
gfyrag deleted the feat/add-gateway-ingress-tls-setting branch July 1, 2025 09:04
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