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

Function getInputArguments

pkg/policies/policies.go:764–788  ·  view source on GitHub ↗

transforms input arguments for policy consumption

(inputs map[string]string)

Source from the content-addressed store, hash-verified

762
763// transforms input arguments for policy consumption
764func getInputArguments(inputs map[string]string) map[string]any {
765 args := make(map[string]any)
766
767 for k, v := range inputs {
768 // Normalize consistently: split on newlines first (multi-value inputs,
769 // e.g. a comma-separated contract value merged with runtime values by
770 // mergeRuntimeInputs), then split each line on commas. Doing both means a
771 // comma-separated segment is always expanded into separate values,
772 // regardless of whether it arrived as a single line or as one of several
773 // merged lines.
774 lines := strings.Split(strings.TrimRight(v, "\n"), "\n")
775 values := make([]string, 0, len(lines))
776 for _, line := range lines {
777 values = append(values, splitArgs(line)...)
778 }
779
780 value := getValue(values)
781 if value == nil {
782 continue
783 }
784 args[k] = value
785 }
786
787 return args
788}
789
790func getValue(values []string) any {
791 lines := make([]string, 0)

Callers 2

TestGetInputArgumentsMethod · 0.85
executeScriptMethod · 0.85

Calls 2

splitArgsFunction · 0.85
getValueFunction · 0.85

Tested by 1

TestGetInputArgumentsMethod · 0.68