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

Fix .Values scoping issue in namespaced-role.yaml #125

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

dac73
Copy link
Contributor

@dac73 dac73 commented Nov 26, 2024

Description

This PR addresses a scoping issue in the namespaced-role.yaml Helm template, where .Values could not be evaluated due to the context being overridden inside a range loop. The error encountered during the Helm upgrade was:

template: mirrord-operator/templates/namespaced-role.yaml:9:24: executing “mirrord-operator/templates/namespaced-role.yaml” at <.Values.role>: can’t evaluate field Values in type interface {}

Root Cause

The range loop changes the context (.) to the current item being iterated (a namespace in roleNamespaces). As a result, .Values could not be accessed directly.

Proposed Fix

  • Use $ to explicitly refer to the top-level context for accessing .Values and for calling nested templates like labels and rules.
  • Ensure consistent access to .Values throughout the template.

Changes Made

  • Updated namespaced-role.yaml to use $ for referencing the top-level context.
  • Preserved compatibility with existing values.yaml configurations.

References

  • Original issue: .Values scoping error during Helm upgrade.

@aviramha
Copy link
Member

Thanks for the contribution! Do you mind adding the test case to test_values directory?

@dac73
Copy link
Contributor Author

dac73 commented Nov 26, 2024

@aviramha operator_role_labels.yaml should cover this change already. Reason for adding this change is that version 1.11.0 fails with: template: mirrord-operator/templates/namespaced-role.yaml:9:24: executing “mirrord-operator/templates/namespaced-role.yaml” at <.Values.role>: can’t evaluate field Values in type interface {}
Will add another test.

@aviramha
Copy link
Member

Thank you!

@aviramha aviramha merged commit 4e3d650 into metalbear-co:main Nov 26, 2024
2 checks passed
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