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
Родитель 33d0f3a2c1
Коммит 427e1d7622
1 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -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
}