MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / MergeRuntimeInputs

Function MergeRuntimeInputs

pkg/policies/runtime_inputs.go:97–113  ·  view source on GitHub ↗

MergeRuntimeInputs returns the contract arguments with the runtime inputs merged in additively: when both define the same key, the runtime value is appended after the contract value (newline-separated) so file-sourced exemptions add to, rather than replace, contract-declared ones. The input maps are

(with, runtimeInputs map[string]string)

Source from the content-addressed store, hash-verified

95// maps are not mutated. Exported so callers assembling runtime inputs (e.g. the
96// CLI's --policy-input-from-file handling) reuse the same multi-value encoding.
97func MergeRuntimeInputs(with, runtimeInputs map[string]string) map[string]string {
98 if len(runtimeInputs) == 0 {
99 return with
100 }
101
102 merged := make(map[string]string, len(with)+len(runtimeInputs))
103 maps.Copy(merged, with)
104 for k, v := range runtimeInputs {
105 if existing := merged[k]; existing != "" {
106 merged[k] = existing + "\n" + v
107 } else {
108 merged[k] = v
109 }
110 }
111
112 return merged
113}
114
115// scopeTracker records, concurrency-safely, which runtime-input scope keys were
116// matched by at least one policy attachment during a material evaluation.

Callers 5

buildRuntimeInputsFunction · 0.92
TestMergeRuntimeInputsFunction · 0.85
forPolicyMethod · 0.85

Calls

no outgoing calls

Tested by 2

TestMergeRuntimeInputsFunction · 0.68