зеркало из https://github.com/docker/engine-api.git
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:
Родитель
33d0f3a2c1
Коммит
427e1d7622
|
@ -7,6 +7,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
|
@ -101,7 +102,7 @@ func imageBuildOptionsToQuery(options types.ImageBuildOptions) (url.Values, erro
|
||||||
}
|
}
|
||||||
query.Set("ulimits", string(ulimitsJSON))
|
query.Set("ulimits", string(ulimitsJSON))
|
||||||
|
|
||||||
buildArgs := runconfig.ConvertKVStringsToMap(options.BuildArgs)
|
buildArgs := convertKVStringsToMap(options.BuildArgs)
|
||||||
buildArgsJSON, err := json.Marshal(buildArgs)
|
buildArgsJSON, err := json.Marshal(buildArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return query, err
|
return query, err
|
||||||
|
@ -119,3 +120,18 @@ func getDockerOS(serverHeader string) string {
|
||||||
}
|
}
|
||||||
return osType
|
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
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче