github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/runconfig/opts/parse.go (about)

     1  package opts // import "github.com/docker/docker/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  }