diff --git a/fleetctl/destroy.go b/fleetctl/destroy.go index 4197e6890..31eb919b6 100644 --- a/fleetctl/destroy.go +++ b/fleetctl/destroy.go @@ -35,6 +35,11 @@ Destroyed units are impossible to start unless re-submitted.`, } func runDestroyUnits(args []string) (exit int) { + if len(args) == 0 { + stderr("No units given") + return 0 + } + units, err := findUnits(args) if err != nil { stderr("%v", err) diff --git a/fleetctl/destroy_test.go b/fleetctl/destroy_test.go index 601b59af8..e10111a9e 100644 --- a/fleetctl/destroy_test.go +++ b/fleetctl/destroy_test.go @@ -53,6 +53,11 @@ func TestRunDestroyUnits(t *testing.T) { []string{"y1", "y2", "y3", "y4", "j1", "j2", "j3", "j4", "j5", "y0"}, 0, }, + { + "destroy null input", + []string{}, + 0, + }, } // Check with two goroutines we don't care we should just get diff --git a/fleetctl/load.go b/fleetctl/load.go index 0f7b0923c..9b1127dab 100644 --- a/fleetctl/load.go +++ b/fleetctl/load.go @@ -46,6 +46,11 @@ func init() { } func runLoadUnits(args []string) (exit int) { + if len(args) == 0 { + stderr("No units given") + return 0 + } + if err := lazyCreateUnits(args); err != nil { stderr("Error creating units: %v", err) return 1 diff --git a/fleetctl/load_test.go b/fleetctl/load_test.go index 01ce9e2de..51b5f2739 100644 --- a/fleetctl/load_test.go +++ b/fleetctl/load_test.go @@ -76,6 +76,11 @@ func TestRunLoadUnits(t *testing.T) { []string{"y1", "y2", "y3", "y4", "load1", "load2", "load3", "load4", "load5", "load6", "y0"}, 1, }, + { + "load null input", + []string{}, + 0, + }, } sharedFlags.NoBlock = true diff --git a/fleetctl/start.go b/fleetctl/start.go index 2ded29539..99e03c2d1 100644 --- a/fleetctl/start.go +++ b/fleetctl/start.go @@ -54,6 +54,11 @@ func init() { } func runStartUnit(args []string) (exit int) { + if len(args) == 0 { + stderr("No units given") + return 0 + } + if err := lazyCreateUnits(args); err != nil { stderr("Error creating units: %v", err) return 1 diff --git a/fleetctl/start_test.go b/fleetctl/start_test.go index c97de662e..8a43b937f 100644 --- a/fleetctl/start_test.go +++ b/fleetctl/start_test.go @@ -111,6 +111,11 @@ func TestRunStartUnits(t *testing.T) { []string{"foo-template@1"}, 1, }, + { + "start null input", + []string{}, + 0, + }, } templateResults := []commandTestResults{ diff --git a/fleetctl/stop.go b/fleetctl/stop.go index 941b33d7b..7ffe26254 100644 --- a/fleetctl/stop.go +++ b/fleetctl/stop.go @@ -52,6 +52,11 @@ func init() { } func runStopUnit(args []string) (exit int) { + if len(args) == 0 { + stderr("No units given") + return 0 + } + units, err := findUnits(args) if err != nil { stderr("%v", err) diff --git a/fleetctl/stop_test.go b/fleetctl/stop_test.go index 536419ec1..708bf42ae 100644 --- a/fleetctl/stop_test.go +++ b/fleetctl/stop_test.go @@ -66,6 +66,11 @@ func TestRunStopUnits(t *testing.T) { []string{"y1", "y2", "y3", "y4", "stop1", "stop2", "stop3", "stop4", "stop5", "y0"}, 0, }, + { + "stop null input", + []string{}, + 0, + }, } sharedFlags.NoBlock = true diff --git a/fleetctl/submit.go b/fleetctl/submit.go index cbfe03f93..1297cff50 100644 --- a/fleetctl/submit.go +++ b/fleetctl/submit.go @@ -36,6 +36,11 @@ func init() { } func runSubmitUnits(args []string) (exit int) { + if len(args) == 0 { + stderr("No units given") + return 0 + } + if err := lazyCreateUnits(args); err != nil { stderr("Error creating units: %v", err) exit = 1 diff --git a/fleetctl/unload.go b/fleetctl/unload.go index 48eb833fc..5bdbff3be 100644 --- a/fleetctl/unload.go +++ b/fleetctl/unload.go @@ -36,6 +36,11 @@ func init() { } func runUnloadUnit(args []string) (exit int) { + if len(args) == 0 { + stderr("No units given") + return 0 + } + units, err := findUnits(args) if err != nil { stderr("%v", err) diff --git a/fleetctl/unload_test.go b/fleetctl/unload_test.go index 8e61b3dd9..169ebfea2 100644 --- a/fleetctl/unload_test.go +++ b/fleetctl/unload_test.go @@ -66,6 +66,11 @@ func TestRunUnloadUnits(t *testing.T) { []string{"y1", "y2", "y3", "y4", "unload1", "unload2", "unload3", "unload4", "unload5", "y0"}, 0, }, + { + "unload null input", + []string{}, + 0, + }, } sharedFlags.NoBlock = true