mirror of https://github.com/docker/docs.git
Merge pull request #17545 from LK4D4/writehs_encode
Use json.Encoder for container.writeHostConfig
This commit is contained in:
commit
f87082f08e
|
@ -5,7 +5,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -163,17 +162,18 @@ func (container *Container) readHostConfig() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) writeHostConfig() error {
|
func (container *Container) writeHostConfig() error {
|
||||||
data, err := json.Marshal(container.hostConfig)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
pth, err := container.hostConfigPath()
|
pth, err := container.hostConfigPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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) {
|
func (container *Container) logEvent(action string) {
|
||||||
|
|
Loading…
Reference in New Issue