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

bugfix/fix-nil-pointer #643

Merged
merged 1 commit into from
Feb 25, 2025
Merged

bugfix/fix-nil-pointer #643

merged 1 commit into from
Feb 25, 2025

Conversation

klinch0
Copy link
Contributor

@klinch0 klinch0 commented Feb 22, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced dashboard and identity management displays with updated branding and localization settings, ensuring a refreshed user interface and experience.
  • Style

    • Streamlined dashboard appearance by removing legacy custom styling, resulting in a more consistent and contemporary look.

@klinch0 klinch0 requested a review from kvaps as a code owner February 22, 2025 11:01
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Feb 22, 2025
Copy link
Contributor

coderabbitai bot commented Feb 22, 2025

Walkthrough

This pull request removes the dashboard image configuration from both the paas-full and paas-hosted bundles, updates the logic for setting the dashboard’s locale and style using a new branding variable, and removes the customStyle property from the dashboard values. Additionally, the keycloak configuration has been updated to introduce a new variable for branding and modify related display fields in the realm specification.

Changes

File(s) Change Summary
packages/core/platform/bundles/paas-full.yaml
packages/core/platform/bundles/paas-hosted.yaml
Removed the dashboard image configuration; updated customLocale to derive its value from a new $branding variable (sourced from a ConfigMap) instead of the old $locale; modified customStyle to reference $logoImage from $cozystackBranding instead of $wlConfigmap.
packages/system/dashboard/values.yaml Removed the customStyle property from the dashboard section, eliminating associated CSS style definitions.
packages/system/keycloak-configure/templates/configure-kk.yaml Introduced the $cozystackBranding variable to retrieve branding details from a ConfigMap; updated the logic to initialize $branding and modified display fields in the ClusterKeycloakRealm spec (renaming displayNameHtml to displayHtmlName and adding a new displayName field).

Sequence Diagram(s)

sequenceDiagram
    participant D as Dashboard Template
    participant TE as Template Engine
    participant CM as ConfigMap (cozystack-branding)
    D->>TE: Render dashboard configuration
    TE->>CM: Lookup branding information
    CM-->>TE: Return branding data
    TE->>D: Update customLocale and customStyle with branding
Loading
sequenceDiagram
    participant KT as Keycloak Template
    participant TE as Template Engine
    participant CM as ConfigMap (cozystack-branding)
    KT->>TE: Render keycloak configuration
    TE->>CM: Retrieve branding details
    CM-->>TE: Return branding info
    TE->>KT: Populate display fields using branding
Loading

Possibly related PRs

  • bugfix/fix-nil-pointer #643: Involved removal of the dashboard image configuration in both the paas-full and paas-hosted bundles.
  • feature/update-dashboard-image #636: Focused on updating the image tag and digest for the dashboard, directly relating to image configuration modifications.
  • feature/add-wl #632: Addressed changes to the customLocale and customStyle variables in the dashboard configuration, paralleling the updates in this PR.

Suggested reviewers

  • kvaps

Poem

I’m just a bunny, hopping by the code,
Watching old settings vanish down the road.
No more image tags to slow our pace,
Branding now leads the stylish race.
With whiskers twitching in delight,
I cheer for changes that make our config bright! 🐇✨


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
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 (1)
packages/system/keycloak-configure/templates/configure-kk.yaml (1)

33-36: Conditional Locale Assignment and Indentation Warning

Initializing $locale with an empty string and then conditionally assigning it using the $wlConfigmap is an effective safeguard against nil pointer exceptions. However, YAMLlint has flagged an indentation warning on line 35. Consider adjusting the indentation of this template directive to align with the YAML formatting expectations, ensuring that linting tools do not raise unnecessary warnings.

🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 35-35: wrong indentation: expected 0 but found 2

(indentation)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 24fa722 and 180834e.

📒 Files selected for processing (4)
  • packages/core/platform/bundles/paas-full.yaml (0 hunks)
  • packages/core/platform/bundles/paas-hosted.yaml (0 hunks)
  • packages/system/dashboard/values.yaml (0 hunks)
  • packages/system/keycloak-configure/templates/configure-kk.yaml (3 hunks)
💤 Files with no reviewable changes (3)
  • packages/system/dashboard/values.yaml
  • packages/core/platform/bundles/paas-full.yaml
  • packages/core/platform/bundles/paas-hosted.yaml
🧰 Additional context used
🪛 YAMLlint (1.35.1)
packages/system/keycloak-configure/templates/configure-kk.yaml

[warning] 35-35: wrong indentation: expected 0 but found 2

(indentation)

🔇 Additional comments (2)
packages/system/keycloak-configure/templates/configure-kk.yaml (2)

10-10: Addition of $wlConfigmap Variable

The new variable $wlConfigmap retrieves the "white-label" ConfigMap from the "cozy-dashboard" namespace. This retrieval is key to conditionally determining the locale later in the template, which helps avoid nil pointer issues when the ConfigMap is missing.


91-94: Updated Display Name Fields in ClusterKeycloakRealm

The conditional block that adds the new displayHtmlName and displayName fields based on the value of $locale is well implemented. Ensure that any downstream components referencing the old field (displayNameHtml) are updated accordingly so that the renaming does not introduce integration issues.

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 (2)
packages/apps/tenant/templates/quota.yaml (1)

1-1: YAMLlint Warning: Likely a False Positive Due to Helm Templating
The linter complains about a syntax error on line 1, but this is expected since Helm templates use special syntax (e.g. {{- if .Values.resources }}). If this warning becomes noisy in CI, consider adding a YAML lint disable comment or configuring the linter to ignore Helm template directives.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

packages/system/keycloak-configure/templates/configure-kk.yaml (1)

33-36: Conditional Locale Assignment: Protecting Against Nil Pointers
The snippet initializes $locale as an empty string and then conditionally assigns it from $wlConfigmap.data only if $wlConfigmap exists. This prevents nil pointer dereferences when the ConfigMap is missing.
Note: The extra indentation on line 35 causes a YAMLlint warning ("wrong indentation: expected 0 but found 2"). Since this is part of Helm templating and does not affect the rendered output, you may either ignore it or adjust the spacing if your linting setup allows.

🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 35-35: wrong indentation: expected 0 but found 2

(indentation)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 180834e and b393235.

📒 Files selected for processing (10)
  • packages/apps/tenant/Chart.yaml (1 hunks)
  • packages/apps/tenant/README.md (1 hunks)
  • packages/apps/tenant/templates/quota.yaml (1 hunks)
  • packages/apps/tenant/values.schema.json (1 hunks)
  • packages/apps/tenant/values.yaml (1 hunks)
  • packages/apps/versions_map (1 hunks)
  • packages/core/platform/bundles/paas-full.yaml (0 hunks)
  • packages/core/platform/bundles/paas-hosted.yaml (0 hunks)
  • packages/system/dashboard/values.yaml (0 hunks)
  • packages/system/keycloak-configure/templates/configure-kk.yaml (3 hunks)
💤 Files with no reviewable changes (3)
  • packages/system/dashboard/values.yaml
  • packages/core/platform/bundles/paas-hosted.yaml
  • packages/core/platform/bundles/paas-full.yaml
✅ Files skipped from review due to trivial changes (1)
  • packages/apps/tenant/Chart.yaml
🧰 Additional context used
🪛 YAMLlint (1.35.1)
packages/apps/tenant/templates/quota.yaml

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

(syntax)

packages/system/keycloak-configure/templates/configure-kk.yaml

[warning] 35-35: wrong indentation: expected 0 but found 2

(indentation)

🔇 Additional comments (8)
packages/apps/tenant/README.md (1)

61-61: Well-documented parameter!

The new resources parameter is properly documented in the README with a clear description and default value. This addition is consistent with the formatting of other parameters in the table.

packages/apps/tenant/values.schema.json (1)

34-39: Proper schema definition for the new resources parameter!

The schema definition for the resources parameter is correctly implemented as an object type with an appropriate description and default value. This matches the implementation in values.yaml and the documentation in README.md.

packages/apps/tenant/values.yaml (2)

9-9: Parameter documentation follows conventions!

The documentation format for the new resources parameter follows the established pattern of other parameters in the file.


16-23: Great implementation with helpful examples!

The resources parameter is correctly initialized with an empty object as the default value, and the commented examples provide clear guidance on how to structure CPU and memory limits/requests. This helps prevent nil pointer errors when the configuration is accessed.

packages/apps/versions_map (1)

107-108: Version mapping updated appropriately!

The version mapping has been correctly updated to lock version 1.7.0 to a specific commit hash and introduce the new 1.7.1 version pointing to HEAD. This follows the established pattern in the file and allows for stable references while development continues.

packages/apps/tenant/templates/quota.yaml (1)

1-17: ResourceQuota Template: Correct Conditional Rendering
The template cleanly checks for the existence of .Values.resources and further nests conditionals for resource requests and limits. This design provides flexible configuration for tenant quotas. The structure is clear and aligns well with Helm templating practices.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

packages/system/keycloak-configure/templates/configure-kk.yaml (2)

10-10: White-Label ConfigMap Retrieval: Preventing Nil Pointer Dereference
The new variable assignment using lookup to fetch the white-label ConfigMap ensures that subsequent references (such as when assigning $locale) don’t attempt to index a nil object. This is an effective measure to fix potential nil pointer issues.


91-94: Updated Keycloak Realm Display Fields: Consistent with Locale Configuration
Changing from displayNameHtml to displayHtmlName and adding a new field displayName (both using the $locale variable) is a solid update. This conditional inclusion ensures that these display fields are only set when a locale value is provided.

@klinch0 klinch0 closed this Feb 25, 2025
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Feb 25, 2025
@klinch0 klinch0 reopened this Feb 25, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Feb 25, 2025
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 (1)
packages/system/keycloak-configure/templates/configure-kk.yaml (1)

33-36: Initialize Branding Safely & Adjust Indentation
Here the variable $branding is initialized with an empty string and conditionally set if $cozystackBranding exists. This prevents nil pointer dereferences when accessing the config’s data.

Note: YAML lint flagged line 35 for unexpected indentation. Consider aligning the action with the surrounding template code for consistency. For example:

-  {{- $branding = index $cozystackBranding.data "branding" }}
+{{- $branding = index $cozystackBranding.data "branding" }}
🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 35-35: wrong indentation: expected 0 but found 2

(indentation)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b393235 and beaf0d5.

📒 Files selected for processing (4)
  • packages/core/platform/bundles/paas-full.yaml (1 hunks)
  • packages/core/platform/bundles/paas-hosted.yaml (1 hunks)
  • packages/system/dashboard/values.yaml (0 hunks)
  • packages/system/keycloak-configure/templates/configure-kk.yaml (3 hunks)
💤 Files with no reviewable changes (1)
  • packages/system/dashboard/values.yaml
🧰 Additional context used
🪛 YAMLlint (1.35.1)
packages/system/keycloak-configure/templates/configure-kk.yaml

[warning] 35-35: wrong indentation: expected 0 but found 2

(indentation)

🔇 Additional comments (6)
packages/system/keycloak-configure/templates/configure-kk.yaml (2)

10-10: Introducing the Branding ConfigMap Lookup
The new variable $cozystackBranding is correctly looked up from the "cozy-system" namespace. The downstream nil-checks (in the block below) help avoid nil pointer issues.


92-95: Apply Branding to Keycloak Realm Spec
The conditional block applies $branding to both displayHtmlName and displayName in the ClusterKeycloakRealm spec. This ensures that if branding is available it will be used to update the display fields and prevents a nil pointer when absent.

packages/core/platform/bundles/paas-full.yaml (2)

249-254: Integrate Dashboard Branding for Custom Locale
This block retrieves the branding configuration using the lookup and dig functions and conditionally applies it to the customLocale field. The use of dig with a default value protects against nil pointers if the ConfigMap does not exist.

Example rendering:

customLocale:
  "Kubeapps": <branding_value>

255-261: Set Custom Style with Dynamic Logo Image
The updated customStyle block conditionally inserts a CSS rule for the .kubeapps-logo based on the presence of a logo image in the branding ConfigMap. This approach helps avoid nil pointer issues and ensures that the style is applied only when available.

packages/core/platform/bundles/paas-hosted.yaml (2)

172-177: Consistent Branding Configuration for Hosted Dashboard
The branding lookup and conditional injection into customLocale mirrors the approach used in paas-full.yaml. Using dig ensures that if the key is missing, a default empty string is returned, thus preventing nil pointer dereferences.

This consistency across bundles is key for maintainability.


178-184: Apply Custom Style Dynamically with Logo Extraction
The customStyle block is updated to include the .kubeapps-logo style only when a logo image exists in the branding ConfigMap. This conditional injection is both safe and efficient.

Copy link
Member

@kvaps kvaps left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 25, 2025
@coderabbitai coderabbitai bot mentioned this pull request Feb 25, 2025
@klinch0 klinch0 changed the title fix nil pointer bugfix/fix-nil-pointer Feb 25, 2025
@kvaps kvaps merged commit a226fdd into aenix-io:main Feb 25, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants