1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Remove usage of runconfig.ConvertKVStringsToMap in the API client library.

It's a very simple function that we can duplicate.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera 2015-12-18 13:25:32 -05:00
parent 839f73c302
commit 747dccde41

View file

@ -7,6 +7,7 @@ import (
"net/url"
"regexp"
"strconv"
"strings"
"github.com/docker/docker/api/types"
"github.com/docker/docker/runconfig"
@ -101,7 +102,7 @@ func imageBuildOptionsToQuery(options types.ImageBuildOptions) (url.Values, erro
}
query.Set("ulimits", string(ulimitsJSON))
buildArgs := runconfig.ConvertKVStringsToMap(options.BuildArgs)
buildArgs := convertKVStringsToMap(options.BuildArgs)
buildArgsJSON, err := json.Marshal(buildArgs)
if err != nil {
return query, err
@ -119,3 +120,18 @@ func getDockerOS(serverHeader string) string {
}
return osType
}
// convertKVStringsToMap converts ["key=value"] to {"key":"value"}
func convertKVStringsToMap(values []string) map[string]string {
result := make(map[string]string, len(values))
for _, value := range values {
kv := strings.SplitN(value, "=", 2)
if len(kv) == 1 {
result[kv[0]] = ""
} else {
result[kv[0]] = kv[1]
}
}
return result
}