1
0
mirror of https://github.com/docker/cli.git synced 2026-01-18 08:21:31 +03:00

Use json.Encoder for container.writeHostConfig

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: cf1a6c08fa03aa7020f8f5b414bb9349a9c8371a
Component: engine
This commit is contained in:
Alexander Morozov
2015-10-30 14:45:35 -07:00
parent ed2cf39b31
commit 7823447431

View File

@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -165,17 +164,18 @@ func (container *Container) readHostConfig() error {
}
func (container *Container) writeHostConfig() error {
data, err := json.Marshal(container.hostConfig)
if err != nil {
return err
}
pth, err := container.hostConfigPath()
if err != nil {
return err
}
return ioutil.WriteFile(pth, data, 0666)
f, err := os.Create(pth)
if err != nil {
return err
}
defer f.Close()
return json.NewEncoder(f).Encode(&container.hostConfig)
}
func (container *Container) logEvent(action string) {