forPolicy returns the runtime inputs that apply to a policy attachment identified by its metadata name and raw ref, together with the scope keys that matched. The returned map merges the global inputs with any scoped entries whose key matches the attachment (additively when they share an input name)
(name, ref string)
| 38 | // entries whose key matches the attachment (additively when they share an |
| 39 | // input name). Returns (nil, nil) when nothing applies. Nil-safe. |
| 40 | func (ri *RuntimeInputs) forPolicy(name, ref string) (map[string]string, []string) { |
| 41 | if ri == nil || (len(ri.Global) == 0 && len(ri.Scoped) == 0) { |
| 42 | return nil, nil |
| 43 | } |
| 44 | |
| 45 | effective := ri.Global |
| 46 | var matched []string |
| 47 | for scope, inputs := range ri.Scoped { |
| 48 | if policyScopeMatches(scope, name, ref) { |
| 49 | matched = append(matched, scope) |
| 50 | effective = MergeRuntimeInputs(effective, inputs) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return effective, matched |
| 55 | } |
| 56 | |
| 57 | // policyScopeMatches reports whether a runtime-input scope key targets the |
| 58 | // policy attachment identified by its metadata name and raw ref. A scope |