diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-04-12 13:35:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 13:35:00 -0400 |
commit | a82ec1be458bb0861fdde8351c0474fc3c3fc9e7 (patch) | |
tree | d9ff092999119d7910aa1f602103c845b7f8b546 /pkg/api/handlers/libpod/containers_create.go | |
parent | 87d129e805c993acbc571597baba8101afd475fe (diff) | |
parent | d8a902a167b91ca4fde4ffeef55e9aa4907ae258 (diff) | |
download | podman-a82ec1be458bb0861fdde8351c0474fc3c3fc9e7.tar.gz podman-a82ec1be458bb0861fdde8351c0474fc3c3fc9e7.tar.bz2 podman-a82ec1be458bb0861fdde8351c0474fc3c3fc9e7.zip |
Merge pull request #13787 from Luap99/nohost-api
API: use no_hosts from containers.conf
Diffstat (limited to 'pkg/api/handlers/libpod/containers_create.go')
-rw-r--r-- | pkg/api/handlers/libpod/containers_create.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/pkg/api/handlers/libpod/containers_create.go b/pkg/api/handlers/libpod/containers_create.go index 61f437faf..4f9dc008d 100644 --- a/pkg/api/handlers/libpod/containers_create.go +++ b/pkg/api/handlers/libpod/containers_create.go @@ -18,7 +18,18 @@ import ( // the new container ID on success along with any warnings. func CreateContainer(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) - var sg specgen.SpecGenerator + conf, err := runtime.GetConfigNoCopy() + if err != nil { + utils.InternalServerError(w, err) + return + } + + // we have to set the default before we decode to make sure the correct default is set when the field is unset + sg := specgen.SpecGenerator{ + ContainerNetworkConfig: specgen.ContainerNetworkConfig{ + UseImageHosts: conf.Containers.NoHosts, + }, + } if err := json.NewDecoder(r.Body).Decode(&sg); err != nil { utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()")) |