Reject unknown keys and non-map entries in rbac.rules

What does this MR do?

The chart renders only apiGroups, resources and verbs from each rbac.rules entry. A misspelled key, such as resource_names, was dropped without a message, so the Role was wider than the user wrote. A null or string entry failed with a raw template error.

This MR fails the render for these cases. The error names the rule index and the unsupported keys. It follows !561 (merged), which did the same for resourceNames and nonResourceURLs.

Upgrade note: helm install and helm upgrade now fail if a rule sets a key other than apiGroups, resources, verbs, resourceNames or nonResourceURLs, or if a rule is not a map. The failure happens at render time. Nothing is applied, and the running Role stays as it is.

  • Fail when a rule sets an unsupported key, and list all such keys in one message.
  • Fail when a rule is not a map.
  • Keep the resourceNames and nonResourceURLs messages, and report them first.
  • Add 5 unit tests and update the values.yaml comment.

What's the best way to test this MR?

helm unittest .
helm template r . --set gitlabUrl=https://gitlab.example.com --set runnerToken=dummy --set rbac.create=true --set "rbac.rules[0].resources[0]=secrets" --set "rbac.rules[0].resource_names[0]=only-this-secret" --show-only templates/role.yaml

The render fails and names rbac.rules[0] and resource_names. On main it prints a rule with no names.

The user docs for this setting are in gitlab-org/gitlab-runner!7629 (merged).

Merge request reports

Loading
Loading