Update code based on review comments

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-06-24 17:17:41 -07:00
parent 854bcc0f7e
commit 77dcaac129
3 changed files with 6 additions and 6 deletions

View File

@ -62,7 +62,7 @@ func Exec(container *libcontainer.Config, term Terminal, rootfs, dataPath string
Pid1StartTime: started, Pid1StartTime: started,
} }
if err := libcontainer.WriteState(dataPath, state); err != nil { if err := libcontainer.SaveState(dataPath, state); err != nil {
command.Process.Kill() command.Process.Kill()
command.Wait() command.Wait()
return -1, err return -1, err

View File

@ -26,7 +26,7 @@ func execAction(context *cli.Context) {
log.Fatal(err) log.Fatal(err)
} }
state, err := libcontainer.LoadState(dataPath) state, err := libcontainer.GetState(dataPath)
if err != nil && !os.IsNotExist(err) { if err != nil && !os.IsNotExist(err) {
log.Fatalf("unable to read state.json: %s", err) log.Fatalf("unable to read state.json: %s", err)
} }

View File

@ -14,9 +14,9 @@ type State struct {
Pid1StartTime string `json:"pid1_start_time,omitempty"` Pid1StartTime string `json:"pid1_start_time,omitempty"`
} }
// WriteState writes the container's runtime state to a state.json file // SaveState writes the container's runtime state to a state.json file
// in the specified path // in the specified path
func WriteState(basePath string, state *State) error { func SaveState(basePath string, state *State) error {
f, err := os.Create(filepath.Join(basePath, "state.json")) f, err := os.Create(filepath.Join(basePath, "state.json"))
if err != nil { if err != nil {
return err return err
@ -26,8 +26,8 @@ func WriteState(basePath string, state *State) error {
return json.NewEncoder(f).Encode(state) return json.NewEncoder(f).Encode(state)
} }
// LoadState reads the state.json file for a running container // GetState reads the state.json file for a running container
func LoadState(basePath string) (*State, error) { func GetState(basePath string) (*State, error) {
f, err := os.Open(filepath.Join(basePath, "state.json")) f, err := os.Open(filepath.Join(basePath, "state.json"))
if err != nil { if err != nil {
return nil, err return nil, err