github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/runconfig/opts/parse.go (about)

     1  package opts // import "github.com/demonoid81/moby/runconfig/opts"
     2  
     3  import (
     4  	"strings"
     5  )
     6  
     7  // ConvertKVStringsToMap converts ["key=value"] to {"key":"value"}
     8  func ConvertKVStringsToMap(values []string) map[string]string {
     9  	result := make(map[string]string, len(values))
    10  	for _, value := range values {
    11  		kv := strings.SplitN(value, "=", 2)
    12  		if len(kv) == 1 {
    13  			result[kv[0]] = ""
    14  		} else {
    15  			result[kv[0]] = kv[1]
    16  		}
    17  	}
    18  
    19  	return result
    20  }