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:
commit
85d7bbf7aa
1 changed files with 10 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue