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

Merge pull request #17528 from LK4D4/todisk_encode

Use json.Encoder for container.toDisk
This commit is contained in:
David Calavera 2015-10-30 14:36:42 -07:00
commit 85d7bbf7aa

View file

@ -112,17 +112,21 @@ func (container *Container) fromDisk() error {
}
func (container *Container) toDisk() error {
data, err := json.Marshal(container)
if err != nil {
return err
}
pth, err := container.jsonPath()
if err != nil {
return err
}
if err := ioutil.WriteFile(pth, data, 0666); err != nil {
jsonSource, err := os.Create(pth)
if err != nil {
return err
}
defer jsonSource.Close()
enc := json.NewEncoder(jsonSource)
// Save container settings
if err := enc.Encode(container); err != nil {
return err
}