alloy icon indicating copy to clipboard operation
alloy copied to clipboard

Fix Helm chart RBAC template to handle empty rule arrays

Open naptalie opened this issue 1 month ago • 1 comments

Summary

  • Fixes RBAC template rendering failure when rbac.rules or rbac.clusterRules are 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:

  1. Check if rule arrays have content before rendering
  2. Output valid YAML empty array syntax [] when arrays are empty
  3. 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

naptalie avatar Nov 16 '25 02:11 naptalie

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 16 '25 02:11 CLAassistant