From 165815fdbffd4b771be71fbe207ad906d042ecea Mon Sep 17 00:00:00 2001 From: HuKeping Date: Fri, 22 Apr 2016 11:01:24 -0400 Subject: [PATCH 1/2] Introduce a ctr wide constant Signed-off-by: Hu Keping --- ctr/const.go | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 ctr/const.go diff --git a/ctr/const.go b/ctr/const.go new file mode 100644 index 0000000..3af854b --- /dev/null +++ b/ctr/const.go @@ -0,0 +1,10 @@ +package main + +// ctr wide constants +const ( + // ExitStatusOK indicates successful completion + ExitStatusOK = 0 + + // ExitStatusMissingArg indicates failure due to missing argument(s) + ExitStatusMissingArg = 1 +) From 10800f62ae8b5909ec8c4fb09dcffa3cca070394 Mon Sep 17 00:00:00 2001 From: HuKeping Date: Fri, 22 Apr 2016 11:08:42 -0400 Subject: [PATCH 2/2] Use constant to replace integer literal Signed-off-by: Hu Keping --- ctr/checkpoint.go | 10 +++++----- ctr/container.go | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ctr/checkpoint.go b/ctr/checkpoint.go index bc02097..622704b 100644 --- a/ctr/checkpoint.go +++ b/ctr/checkpoint.go @@ -43,7 +43,7 @@ func listCheckpoints(context *cli.Context) { id = context.Args().First() ) if id == "" { - fatal("container id cannot be empty", 1) + fatal("container id cannot be empty", ExitStatusMissingArg) } resp, err := c.ListCheckpoint(netcontext.Background(), &types.ListCheckpointRequest{ Id: id, @@ -88,10 +88,10 @@ var createCheckpointCommand = cli.Command{ name = context.Args().Get(1) ) if containerID == "" { - fatal("container id at cannot be empty", 1) + fatal("container id at cannot be empty", ExitStatusMissingArg) } if name == "" { - fatal("checkpoint name cannot be empty", 1) + fatal("checkpoint name cannot be empty", ExitStatusMissingArg) } c := getClient(context) if _, err := c.CreateCheckpoint(netcontext.Background(), &types.CreateCheckpointRequest{ @@ -118,10 +118,10 @@ var deleteCheckpointCommand = cli.Command{ name = context.Args().Get(1) ) if containerID == "" { - fatal("container id at cannot be empty", 1) + fatal("container id at cannot be empty", ExitStatusMissingArg) } if name == "" { - fatal("checkpoint name cannot be empty", 1) + fatal("checkpoint name cannot be empty", ExitStatusMissingArg) } c := getClient(context) if _, err := c.DeleteCheckpoint(netcontext.Background(), &types.DeleteCheckpointRequest{ diff --git a/ctr/container.go b/ctr/container.go index ab44606..2541aca 100644 --- a/ctr/container.go +++ b/ctr/container.go @@ -146,10 +146,10 @@ var startCommand = cli.Command{ path = context.Args().Get(1) ) if path == "" { - fatal("bundle path cannot be empty", 1) + fatal("bundle path cannot be empty", ExitStatusMissingArg) } if id == "" { - fatal("container id cannot be empty", 1) + fatal("container id cannot be empty", ExitStatusMissingArg) } bpath, err := filepath.Abs(path) if err != nil { @@ -336,7 +336,7 @@ var pauseCommand = cli.Command{ Action: func(context *cli.Context) { id := context.Args().First() if id == "" { - fatal("container id cannot be empty", 1) + fatal("container id cannot be empty", ExitStatusMissingArg) } c := getClient(context) _, err := c.UpdateContainer(netcontext.Background(), &types.UpdateContainerRequest{ @@ -356,7 +356,7 @@ var resumeCommand = cli.Command{ Action: func(context *cli.Context) { id := context.Args().First() if id == "" { - fatal("container id cannot be empty", 1) + fatal("container id cannot be empty", ExitStatusMissingArg) } c := getClient(context) _, err := c.UpdateContainer(netcontext.Background(), &types.UpdateContainerRequest{ @@ -388,7 +388,7 @@ var killCommand = cli.Command{ Action: func(context *cli.Context) { id := context.Args().First() if id == "" { - fatal("container id cannot be empty", 1) + fatal("container id cannot be empty", ExitStatusMissingArg) } c := getClient(context) if _, err := c.Signal(netcontext.Background(), &types.SignalRequest{