MCPcopy Create free account
hub / github.com/docker/cli / ConvertKVStringsToMap

Function ConvertKVStringsToMap

opts/parse.go:42–50  ·  view source on GitHub ↗

ConvertKVStringsToMap converts ["key=value"] to {"key":"value"}

(values []string)

Source from the content-addressed store, hash-verified

40
41// ConvertKVStringsToMap converts ["key=value"] to {"key":"value"}
42func ConvertKVStringsToMap(values []string) map[string]string {
43 result := make(map[string]string, len(values))
44 for _, value := range values {
45 k, v, _ := strings.Cut(value, "=")
46 result[k] = v
47 }
48
49 return result
50}
51
52// ConvertKVStringsToMapWithNil converts ["key=value"] to {"key":"value"}
53// but set unset keys to nil - meaning the ones with no "=" in them.

Callers 1

SetMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…