alloy
alloy copied to clipboard
Fix Helm chart RBAC template to handle empty rule arrays
Summary
- Fixes RBAC template rendering failure when
rbac.rulesorrbac.clusterRulesare set to empty arrays - Adds conditional checks to output valid YAML empty array syntax when rule arrays are empty
- Includes test case for empty RBAC rules configuration
Problem
The Grafana Alloy Helm chart fails to template when rbac.rules or rbac.clusterRules configuration fields are set to empty arrays. This produces a YAML parsing error because the toYaml filter outputs an empty string for empty arrays, leaving the rules: key without a valid value.
Solution
Modified rbac.yaml to:
- Check if rule arrays have content before rendering
- Output valid YAML empty array syntax
[]when arrays are empty - Handle both Role and ClusterRole configurations
Test Plan
- Added test case configuration in rbac-empty-rules-values.yaml
- Verified template renders successfully with empty RBAC rules:
helm template test charts/alloy -f charts/alloy/ci/rbac-empty-rules-values.yaml - Generated test outputs verify valid YAML structure
Fixes #4778
🤖 Generated with Claude Code