Skip to content

Commit

Permalink
vultr: fix empty port range parsing (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdmulloy authored and squat committed Jun 1, 2018
1 parent 237b7f7 commit bcf9459
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions vultr/resource_firewall_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ func splitFirewallRule(portRange string) (int, int, error) {
return 0, 0, nil
}
ports := strings.Split(portRange, "-")
if len(strings.TrimSpace(ports[0])) == 0 {
return 0, 0, nil
}
from, err := strconv.Atoi(strings.TrimSpace(ports[0]))
if err != nil {
return 0, 0, err
Expand Down
2 changes: 1 addition & 1 deletion vultr/resource_firewall_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestSplitFirewallRule(t *testing.T) {
portRange: "-",
from: 0,
to: 0,
err: true,
err: false,
},
{
portRange: "22",
Expand Down

0 comments on commit bcf9459

Please sign in to comment.