Skip to content

Commit

Permalink
Better error handling for int check
Browse files Browse the repository at this point in the history
  • Loading branch information
Cellebyte committed Jun 25, 2024
1 parent 97d8b08 commit ed4b5a9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/kubevip/config_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,13 @@ func ParseEnvironment(c *Config) error {
if err != nil {
return err
}
if i > math.MaxInt32 && math.MaxInt < math.MaxInt64 {
return fmt.Errorf("system does not support int64 natively only [int%d]", bits.OnesCount(math.MaxInt)+1)
if i >= 0 && i <= math.MaxInt {
c.RoutingTableID = int(i)
return nil
} else if i < 0 {
return fmt.Errorf("no support of negative [%d] in env var %q", i, vipRoutingTableID)
}
c.RoutingTableID = int(i)
return fmt.Errorf("no support for int64 natively on system only [int%d]", bits.OnesCount(math.MaxUint))
}

// Routing Table Type
Expand Down

0 comments on commit ed4b5a9

Please sign in to comment.