Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1475 from endocode/dongsu/fleetctl-error-empty-units
Browse files Browse the repository at this point in the history
fleetctl: check for empty input unit strings
  • Loading branch information
jonboulle committed Mar 10, 2016
2 parents 5021cd5 + 80d37bb commit 04d539f
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fleetctl/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions fleetctl/destroy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions fleetctl/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions fleetctl/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions fleetctl/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions fleetctl/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ func TestRunStartUnits(t *testing.T) {
[]string{"foo-template@1"},
1,
},
{
"start null input",
[]string{},
0,
},
}

templateResults := []commandTestResults{
Expand Down
5 changes: 5 additions & 0 deletions fleetctl/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions fleetctl/stop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions fleetctl/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions fleetctl/unload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions fleetctl/unload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 04d539f

Please sign in to comment.