Cleanup and rename loadContainer to loadConfig

Signed-off-by: Michael Crosby <michael@docker.com>
This commit is contained in:
Michael Crosby 2014-08-12 12:03:53 -07:00
parent 52ba97e3b1
commit 7d1ba0698f
8 changed files with 29 additions and 38 deletions

View File

@ -15,7 +15,7 @@ var configCommand = cli.Command{
}
func configAction(context *cli.Context) {
container, err := loadContainer()
container, err := loadConfig()
if err != nil {
log.Fatal(err)
}

View File

@ -25,7 +25,7 @@ var execCommand = cli.Command{
func execAction(context *cli.Context) {
var exitCode int
container, err := loadContainer()
container, err := loadConfig()
if err != nil {
log.Fatal(err)
}

View File

@ -36,7 +36,7 @@ func execFuncAction(context *cli.Context) {
var exitCode int
config, err := loadContainer()
config, err := loadConfig()
if err != nil {
log.Fatal(err)
}

View File

@ -26,7 +26,7 @@ var (
func initAction(context *cli.Context) {
runtime.LockOSThread()
container, err := loadContainer()
container, err := loadConfig()
if err != nil {
log.Fatal(err)
}

View File

@ -29,27 +29,6 @@ func init() {
}
}
func preload(context *cli.Context) error {
if logPath != "" {
if err := openLog(logPath); err != nil {
return err
}
}
return nil
}
func runFunc(f *rFunc) {
userArgs := findUserArgs()
config, err := loadConfigFromFd()
if err != nil {
log.Fatalf("unable to receive config from sync pipe: %s", err)
}
f.Action(config, userArgs)
}
func main() {
// we need to check our argv 0 for any registred functions to run instead of the
// normal cli code path

View File

@ -34,7 +34,7 @@ func unpauseAction(context *cli.Context) {
}
func toggle(state cgroups.FreezerState) error {
container, err := loadContainer()
container, err := loadConfig()
if err != nil {
return err
}

View File

@ -16,7 +16,7 @@ var statsCommand = cli.Command{
}
func statsAction(context *cli.Context) {
container, err := loadContainer()
container, err := loadConfig()
if err != nil {
log.Fatal(err)
}

View File

@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"github.com/codegangsta/cli"
"github.com/docker/libcontainer"
"github.com/docker/libcontainer/syncpipe"
)
@ -16,7 +17,7 @@ type rFunc struct {
Action func(*libcontainer.Config, []string)
}
func loadContainer() (*libcontainer.Config, error) {
func loadConfig() (*libcontainer.Config, error) {
f, err := os.Open(filepath.Join(dataPath, "container.json"))
if err != nil {
return nil, err
@ -42,16 +43,6 @@ func openLog(name string) error {
return nil
}
func loadContainerFromJson(rawData string) (*libcontainer.Config, error) {
var container *libcontainer.Config
if err := json.Unmarshal([]byte(rawData), &container); err != nil {
return nil, err
}
return container, nil
}
func findUserArgs() []string {
i := 0
for _, a := range os.Args {
@ -80,3 +71,24 @@ func loadConfigFromFd() (*libcontainer.Config, error) {
return config, nil
}
func preload(context *cli.Context) error {
if logPath != "" {
if err := openLog(logPath); err != nil {
return err
}
}
return nil
}
func runFunc(f *rFunc) {
userArgs := findUserArgs()
config, err := loadConfigFromFd()
if err != nil {
log.Fatalf("unable to receive config from sync pipe: %s", err)
}
f.Action(config, userArgs)
}