Skip to content

[platform] Introduce cluster-domain option and unhardcode cozy.local - #1039

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
cluster-domain
Jun 10, 2025
Merged

Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
cluster-domain

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Jun 9, 2025 •

Copy link
Copy Markdown
Member

Signed-off-by: Andrei Kvapil [email protected]

Summary by CodeRabbit

  • New Features

    • Dynamic cluster domain configuration is now propagated to multiple components, allowing them to use the cluster domain value from a central ConfigMap instead of a hardcoded value.
    • The cluster domain is now injected into ClickHouse, Kubernetes, NATS, Keycloak, and various operator releases for improved flexibility and consistency.
  • Chores

    • Updated chart versions for ClickHouse, Kubernetes, and NATS applications.
    • Refreshed version references in the versions map to reflect the latest releases.

@coderabbitai

coderabbitai Bot commented Jun 9, 2025 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces dynamic cluster domain configuration across multiple components by extracting the domain from the "cozystack" ConfigMap. The domain is injected into ClickHouse, NATS, Kubernetes, Keycloak, and several operator releases, replacing hardcoded values. Chart versions and the versions map are also updated to reflect these changes.

Changes

File(s) Change Summary
packages/apps/clickhouse/Chart.yaml
packages/apps/kubernetes/Chart.yaml
packages/apps/nats/Chart.yaml
Chart version increments for ClickHouse, Kubernetes, and NATS.
packages/apps/clickhouse/templates/clickhouse.yaml
packages/apps/nats/templates/nats.yaml
packages/apps/kubernetes/templates/helmreleases/vertical-pod-autoscaler.yaml
packages/system/keycloak/templates/sts.yaml
Domain suffix is now dynamically extracted from the "cozystack" ConfigMap and injected into templates.
packages/core/platform/bundles/distro-full.yaml
packages/core/platform/bundles/distro-hosted.yaml
packages/core/platform/bundles/paas-full.yaml
packages/core/platform/bundles/paas-hosted.yaml
Cluster domain is extracted and propagated as a configuration value to multiple Helm releases.
packages/apps/versions_map Updates version references and HEAD designations for ClickHouse, Kubernetes, and NATS.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HelmTemplate
    participant K8sAPI
    participant ConfigMap
    participant Component

    User->>HelmTemplate: Deploy chart
    HelmTemplate->>K8sAPI: Get "cozystack" ConfigMap (cluster-domain)
    K8sAPI->>ConfigMap: Retrieve cluster-domain value
    ConfigMap-->>K8sAPI: Return value or default ("cozy.local")
    K8sAPI-->>HelmTemplate: Provide cluster-domain
    HelmTemplate->>Component: Inject cluster-domain into configuration
    Component-->>User: Runs with correct domain settings
Loading

Possibly related PRs

  • cozystack/cozystack#569: Updates version references for ClickHouse, Kubernetes, and NATS in the versions_map file, which is directly related to the current PR's version mapping changes.
  • cozystack/cozystack#475: Adds the initial Keycloak Helm chart and deployment manifests, upon which the current PR builds by introducing dynamic cluster domain configuration.

Suggested labels

enhancement

Suggested reviewers

  • klinch0

Poem

In the warren where clusters abound,
A rabbit found domains to be sound.
No more hardcoded, static or stale—
Now "cozystack" tells the tale!
Charts and bundles all hop in line,
Dynamic domains—oh, how divine!
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between df7772b and cee820e.

📒 Files selected for processing (12)
  • packages/apps/clickhouse/Chart.yaml (1 hunks)
  • packages/apps/clickhouse/templates/clickhouse.yaml (2 hunks)
  • packages/apps/kubernetes/Chart.yaml (1 hunks)
  • packages/apps/kubernetes/templates/helmreleases/vertical-pod-autoscaler.yaml (2 hunks)
  • packages/apps/nats/Chart.yaml (1 hunks)
  • packages/apps/nats/templates/nats.yaml (2 hunks)
  • packages/apps/versions_map (3 hunks)
  • packages/core/platform/bundles/distro-full.yaml (4 hunks)
  • packages/core/platform/bundles/distro-hosted.yaml (4 hunks)
  • packages/core/platform/bundles/paas-full.yaml (5 hunks)
  • packages/core/platform/bundles/paas-hosted.yaml (5 hunks)
  • packages/system/keycloak/templates/sts.yaml (2 hunks)

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

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

♻️ Duplicate comments (1)
packages/apps/kubernetes/templates/helmreleases/vertical-pod-autoscaler.yaml (1)

1-2: Duplicate: Handle missing ConfigMap to prevent runtime errors
Same as in other templates, wrap lookup with default to ensure a non-nil .data and avoid panics.

🧰 Tools
🪛 YAMLlint (1.37.1)

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

(syntax)

🧹 Nitpick comments (19)
packages/system/keycloak/templates/sts.yaml (1)

117-117: Refactor Java opts via printf: For clearer templating and consistent quoting, use printf instead of inline string concatenation.

Example diff:

-             value: "-Djgroups.dns.query=keycloak-headless.cozy-keycloak.svc.{{ $clusterDomain }}"
+             value: {{ printf "\"-Djgroups.dns.query=keycloak-headless.cozy-keycloak.svc.%s\"" $clusterDomain }}
packages/apps/nats/templates/nats.yaml (1)

56-58: Quote dynamic cluster domain for YAML safety
When injecting {{ $clusterDomain }}, wrap the value in quotes to avoid parsing issues:

-             k8sClusterDomain: {{ $clusterDomain }}
+             k8sClusterDomain: "{{ $clusterDomain }}"
packages/core/platform/bundles/distro-full.yaml (3)

17-21: Promote DRY: Extract cluster domain lookup
Repeated cluster-domain retrieval across bundles suggests centralizing this Helm logic into a shared helper (e.g., {{ include "cozystack.clusterDomain" . }}) for maintainability.


130-133: Quote cluster domain value
Wrap {{ $clusterDomain }} in quotes to ensure valid YAML even if the domain contains special characters:

-      clusterName: {{ $clusterDomain }}
+      clusterName: "{{ $clusterDomain }}"

147-150: Quote cluster domain for YAML
For consistency and to avoid parsing issues, wrap the domain in quotes:

-      kubernetesServiceDnsDomain: {{ $clusterDomain }}
+      kubernetesServiceDnsDomain: "{{ $clusterDomain }}"
packages/core/platform/bundles/distro-hosted.yaml (3)

17-21: Promote DRY: Extract cluster domain lookup
Centralize cluster-domain lookup into a shared Helm template helper (cozystack.clusterDomain) to avoid duplication across bundles.


92-95: Quote cluster domain in values
Wrap clusterName value in quotes for robust YAML:

-      clusterName: {{ $clusterDomain }}
+      clusterName: "{{ $clusterDomain }}"

109-112: Quote dynamic domain for YAML safety
Wrap the domain in quotes to avoid parsing issues:

-      kubernetesServiceDnsDomain: {{ $clusterDomain }}
+      kubernetesServiceDnsDomain: "{{ $clusterDomain }}"
packages/apps/kubernetes/templates/helmreleases/vertical-pod-autoscaler.yaml (1)

18-18: Quote injected domain in Prometheus address
Wrap {{ $clusterDomain }} in quotes within the URL to maintain valid YAML:

-      prometheus-address: http://vmselect-shortterm.{{ $targetTenant }}.svc.{{ $clusterDomain }}:8481/select/0/prometheus/
+      prometheus-address: "http://vmselect-shortterm.{{ $targetTenant }}.svc.{{ $clusterDomain }}:8481/select/0/prometheus/"
packages/core/platform/bundles/paas-full.yaml (5)

2-2: Wrap $clusterDomain default in quotes
Unquoted template values containing dots can be misinterpreted by YAML parsers.


26-30: Quote injected cluster domain
Ensure valid YAML by wrapping the template in quotes:

-          domain: {{ $clusterDomain }}
+          domain: "{{ $clusterDomain }}"

202-205: Quote clusterName for mariadb-operator
Wrap the injected domain to avoid parsing issues:

-      clusterName: {{ $clusterDomain }}
+      clusterName: "{{ $clusterDomain }}"

217-219: Quote kubernetesServiceDnsDomain
Add quotes around the template to maintain YAML validity:

-      kubernetesServiceDnsDomain: {{ $clusterDomain }}
+      kubernetesServiceDnsDomain: "{{ $clusterDomain }}"

385-389: Quote Prometheus address templating
Wrap the full URL (including the templated domain) in quotes:

-          prometheus-address: http://vmselect-shortterm.tenant-root.svc.{{ $clusterDomain }}:8481/select/0/prometheus/
+          prometheus-address: "http://vmselect-shortterm.tenant-root.svc.{{ $clusterDomain }}:8481/select/0/prometheus/"
packages/core/platform/bundles/paas-hosted.yaml (5)

2-2: Wrap $clusterDomain default in quotes
As above, quote template values containing dots to ensure proper YAML parsing.


26-30: Quote injected cluster domain

-          domain: {{ $clusterDomain }}
+          domain: "{{ $clusterDomain }}"

101-104: Quote clusterName for mariadb-operator

-      clusterName: {{ $clusterDomain }}
+      clusterName: "{{ $clusterDomain }}"

116-119: Quote kubernetesServiceDnsDomain

-      kubernetesServiceDnsDomain: {{ $clusterDomain }}
+      kubernetesServiceDnsDomain: "{{ $clusterDomain }}"

221-225: Quote Prometheus address in vpa config

-          prometheus-address: http://vmselect-shortterm.tenant-root.svc.{{ $clusterDomain }}:8481/select/0/prometheus/
+          prometheus-address: "http://vmselect-shortterm.tenant-root.svc.{{ $clusterDomain }}:8481/select/0/prometheus/"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c467ed7 and df7772b.

📒 Files selected for processing (12)
  • packages/apps/clickhouse/Chart.yaml (1 hunks)
  • packages/apps/clickhouse/templates/clickhouse.yaml (2 hunks)
  • packages/apps/kubernetes/Chart.yaml (1 hunks)
  • packages/apps/kubernetes/templates/helmreleases/vertical-pod-autoscaler.yaml (2 hunks)
  • packages/apps/nats/Chart.yaml (1 hunks)
  • packages/apps/nats/templates/nats.yaml (2 hunks)
  • packages/apps/versions_map (3 hunks)
  • packages/core/platform/bundles/distro-full.yaml (4 hunks)
  • packages/core/platform/bundles/distro-hosted.yaml (4 hunks)
  • packages/core/platform/bundles/paas-full.yaml (5 hunks)
  • packages/core/platform/bundles/paas-hosted.yaml (5 hunks)
  • packages/system/keycloak/templates/sts.yaml (2 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
packages/apps/nats/templates/nats.yaml

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

(syntax)

packages/apps/kubernetes/templates/helmreleases/vertical-pod-autoscaler.yaml

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

(syntax)

packages/apps/clickhouse/templates/clickhouse.yaml

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

(syntax)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (7)
packages/apps/kubernetes/Chart.yaml (1)

19-19: Bump chart version: Version increment to 0.23.1 aligns with the coordinated rollout of the dynamic cluster-domain feature across platform charts.

packages/apps/clickhouse/Chart.yaml (1)

19-19: Updated chart version: The bump to 0.9.2 corresponds to the template changes for dynamic cluster-domain resolution.

packages/apps/nats/Chart.yaml (1)

19-19: Incremented chart version: Version updated to 0.6.1 in lockstep with the domain‐parameterization changes applied across other charts.

packages/apps/clickhouse/templates/clickhouse.yaml (1)

37-37: Dynamic clusterDomain used: The namespaceDomainPattern now correctly references the templated cluster-domain value.

packages/apps/versions_map (3)

73-73:

Details

✅ Verification successful

Verify Chart.yaml bump for Kubernetes
Ensure that the Kubernetes chart version in packages/apps/kubernetes/Chart.yaml has been updated to 0.23.1 to match this mapping.


🏁 Script executed:

#!/bin/bash
# Validate Kubernetes Chart.yaml version matches versions_map
rg "^version:\\s*0\\.23\\.1" packages/apps/kubernetes/Chart.yaml

Length of output: 79


Kubernetes Chart.yaml version matches versions_map
The Kubernetes chart version in packages/apps/kubernetes/Chart.yaml is correctly set to 0.23.1, matching the mapping in versions_map.


13-13:

Details

✅ Verification successful

Verify Chart.yaml bump for ClickHouse
Ensure that the ClickHouse chart version in packages/apps/clickhouse/Chart.yaml has been updated to 0.9.2 to match this mapping.


🏁 Script executed:

#!/bin/bash
# Validate ClickHouse Chart.yaml version matches versions_map
rg "^version:\\s*0\\.9\\.2" packages/apps/clickhouse/Chart.yaml

Length of output: 77


ClickHouse Chart.yaml version matches versions_map
The version in packages/apps/clickhouse/Chart.yaml is correctly set to 0.9.2, aligning with packages/apps/versions_map. No further updates needed.


92-93:

Details

✅ Verification successful

Verify NATS Chart.yaml version bump
Confirm that the NATS chart version in packages/apps/nats/Chart.yaml has been upgraded to 0.6.1 to align with this mapping.


🏁 Script executed:

#!/bin/bash
# Validate NATS Chart.yaml version matches versions_map
rg "^version:\\s*0\\.6\\.1" packages/apps/nats/Chart.yaml

Length of output: 71


NATS Chart.yaml Version Verified
The version field in packages/apps/nats/Chart.yaml is set to 0.6.1, matching the entry in packages/apps/versions_map.

  • packages/apps/nats/Chart.yaml: version: 0.6.1

Comment on lines +1 to +2
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}

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.

🛠️ Refactor suggestion

Guard against missing ConfigMap: Directly indexing .data on a nil lookup result will panic if the ConfigMap doesn’t exist. Wrap the lookup in a default (or a with block) to ensure .data is always a map.

Proposed diff:

- {{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
- {{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
+ {{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" | default (dict "data" (dict)) }}
+ {{- $clusterDomain := index $cozyConfig.data "cluster-domain" | default "cozy.local" }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" | default (dict "data" (dict)) }}
{{- $clusterDomain := index $cozyConfig.data "cluster-domain" | default "cozy.local" }}
🧰 Tools
🪛 YAMLlint (1.37.1)

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

(syntax)

🤖 Prompt for AI Agents
In packages/apps/clickhouse/templates/clickhouse.yaml at lines 1 to 2, the code
directly accesses .data on the result of lookup, which can be nil if the
ConfigMap does not exist, causing a panic. To fix this, wrap the lookup call in
a default or with block to ensure that .data is always a valid map before
indexing it. This prevents runtime errors when the ConfigMap is missing.

@@ -1,5 +1,6 @@
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $host := index $cozyConfig.data "root-host" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}

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.

🛠️ Refactor suggestion

Handle missing ConfigMap: As with ClickHouse, a nil lookup causes a crash when indexing .data. Wrap $cozyConfig in a default to guarantee a .data map.

Example diff:

- {{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
+ {{- $clusterDomain := index ($cozyConfig | default (dict "data" (dict))).data "cluster-domain" | default "cozy.local" }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
{{- $clusterDomain := index ($cozyConfig | default (dict "data" (dict))).data "cluster-domain" | default "cozy.local" }}
🤖 Prompt for AI Agents
In packages/system/keycloak/templates/sts.yaml at line 3, the code assigns
$clusterDomain by indexing $cozyConfig.data without ensuring $cozyConfig is not
nil, which can cause a crash. To fix this, wrap $cozyConfig in a default
function that provides an empty map if $cozyConfig is nil, ensuring that
indexing .data is safe and does not cause a runtime error.

Comment on lines +1 to +2
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}

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.

🛠️ Refactor suggestion

⚠️ Potential issue

Handle missing ConfigMap to prevent runtime errors
lookup can return nil if the ConfigMap is absent, causing index to panic. Wrap the lookup call with a default to guarantee a non-nil .data map:

- {{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
+ {{- $cozyConfig := default (dict "data" (dict)) (lookup "v1" "ConfigMap" "cozy-system" "cozystack") }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
{{- $cozyConfig := default (dict "data" (dict)) (lookup "v1" "ConfigMap" "cozy-system" "cozystack") }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
🧰 Tools
🪛 YAMLlint (1.37.1)

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

(syntax)

🤖 Prompt for AI Agents
In packages/apps/nats/templates/nats.yaml at lines 1 to 2, the lookup call for
the ConfigMap may return nil if the ConfigMap is missing, causing the subsequent
index call on .data to panic. To fix this, wrap the lookup call with a default
that provides an empty ConfigMap object or at least a non-nil .data map,
ensuring that the index function always operates on a valid map and preventing
runtime errors.

Comment on lines 1 to +2
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}

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.

🛠️ Refactor suggestion

⚠️ Potential issue

Handle ConfigMap lookup nil case
Guard against a missing ConfigMap by defaulting to an empty data map:

- {{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
- {{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
+ {{- $cozyConfig := default (dict "data" (dict)) (lookup "v1" "ConfigMap" "cozy-system" "cozystack") }}
+ {{- $clusterDomain := default "cozy.local" (index $cozyConfig.data "cluster-domain") }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
{{- $cozyConfig := default (dict "data" (dict)) (lookup "v1" "ConfigMap" "cozy-system" "cozystack") }}
{{- $clusterDomain := default "cozy.local" (index $cozyConfig.data "cluster-domain") }}
🧰 Tools
🪛 YAMLlint (1.37.1)

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

(syntax)

🤖 Prompt for AI Agents
In packages/core/platform/bundles/distro-full.yaml at lines 1 to 2, the code
does not handle the case where the ConfigMap lookup returns nil, which can cause
errors when accessing its data. Add a guard to check if the lookup result is nil
and default to an empty map for the data field before accessing
"cluster-domain". This ensures safe access and prevents runtime errors.

Comment on lines 1 to +2
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}

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.

🛠️ Refactor suggestion

⚠️ Potential issue

Handle ConfigMap lookup nil case
Guard against a missing ConfigMap by defaulting to an empty data map:

- {{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
- {{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
+ {{- $cozyConfig := default (dict "data" (dict)) (lookup "v1" "ConfigMap" "cozy-system" "cozystack") }}
+ {{- $clusterDomain := default "cozy.local" (index $cozyConfig.data "cluster-domain") }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
{{- $cozyConfig := default (dict "data" (dict)) (lookup "v1" "ConfigMap" "cozy-system" "cozystack") }}
{{- $clusterDomain := default "cozy.local" (index $cozyConfig.data "cluster-domain") }}
🧰 Tools
🪛 YAMLlint (1.37.1)

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

(syntax)

🤖 Prompt for AI Agents
In packages/core/platform/bundles/distro-hosted.yaml at lines 1 to 2, the lookup
for the ConfigMap "cozystack" in namespace "cozy-system" may return nil if the
ConfigMap is missing, which can cause errors when accessing its data. Add a
guard to check if the lookup result is nil and if so, default $cozyConfig to an
object with an empty data map to safely handle missing ConfigMap cases.

Comment on lines 1 to +2
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}

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.

🛠️ Refactor suggestion

Add validation for missing ConfigMap
You should guard the result of lookup before indexing .data, otherwise a missing cozystack ConfigMap will panic.

Consider adding right after line 1:

{{- if not $cozyConfig }}
{{-   fail "ERROR: cozystack ConfigMap not found in namespace cozy-system" }}
{{- end }}
🧰 Tools
🪛 YAMLlint (1.37.1)

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

(syntax)

🤖 Prompt for AI Agents
In packages/core/platform/bundles/paas-full.yaml at lines 1 to 2, the code uses
lookup to get the cozystack ConfigMap but does not check if the result is nil
before accessing .data, which can cause a panic if the ConfigMap is missing. To
fix this, add a conditional check right after line 1 to verify if $cozyConfig is
nil, and if so, call fail with an error message indicating the ConfigMap was not
found in the cozy-system namespace. This will prevent runtime errors by stopping
execution with a clear error when the ConfigMap is missing.

Comment on lines 1 to +2
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}

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.

🛠️ Refactor suggestion

Add validation for missing ConfigMap
Mirror the guard from paas-full.yaml to prevent panics when the ConfigMap is absent.

🧰 Tools
🪛 YAMLlint (1.37.1)

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

(syntax)

🤖 Prompt for AI Agents
In packages/core/platform/bundles/paas-hosted.yaml at lines 1 to 2, the code
assigns $cozyConfig without checking if the ConfigMap exists, which can cause
panics if it's missing. Add a validation guard similar to the one in
paas-full.yaml by checking if $cozyConfig is nil before accessing its data. If
$cozyConfig is nil, handle the case gracefully to prevent runtime errors.

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.

1 participant