summaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2019-01-09 09:07:06 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-01-09 14:36:48 +0900
commit1d14b8ecfba61de524e0266e4a0fddb3b111f235 (patch)
tree8e66d6dada1377f85e58669c416f7f4cf993ee34 /cmd
parent0ae389ad1e7daeaeb354cd4be76b13ece9153e00 (diff)
silence staticcheck warnings
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gobgp/bmp.go2
-rw-r--r--cmd/gobgp/global.go8
-rw-r--r--cmd/gobgp/mrt.go4
-rw-r--r--cmd/gobgp/neighbor.go12
-rw-r--r--cmd/gobgp/policy.go13
-rw-r--r--cmd/gobgp/vrf.go8
6 files changed, 23 insertions, 24 deletions
diff --git a/cmd/gobgp/bmp.go b/cmd/gobgp/bmp.go
index 7e9754d9..8fd61ff9 100644
--- a/cmd/gobgp/bmp.go
+++ b/cmd/gobgp/bmp.go
@@ -53,7 +53,7 @@ func modBmpServer(cmdType string, args []string) error {
if bmpOpts.StatisticsTimeout >= 0 && bmpOpts.StatisticsTimeout <= 65535 {
statisticsTimeout = bmpOpts.StatisticsTimeout
} else {
- return fmt.Errorf("invalid statistics-timeout value. it must be in the range 0-65535. default value is 0 and means disabled.")
+ return fmt.Errorf("invalid statistics-timeout value. it must be in the range 0-65535. default value is 0 and means disabled")
}
policyType := api.AddBmpRequest_PRE
diff --git a/cmd/gobgp/global.go b/cmd/gobgp/global.go
index 467824a0..fe53242f 100644
--- a/cmd/gobgp/global.go
+++ b/cmd/gobgp/global.go
@@ -123,18 +123,14 @@ func redirectParser(args []string) ([]bgp.ExtendedCommunityInterface, error) {
if err != nil {
return nil, err
}
- switch rt.(type) {
+ switch r := rt.(type) {
case *bgp.TwoOctetAsSpecificExtended:
- r := rt.(*bgp.TwoOctetAsSpecificExtended)
return []bgp.ExtendedCommunityInterface{bgp.NewRedirectTwoOctetAsSpecificExtended(r.AS, r.LocalAdmin)}, nil
case *bgp.IPv4AddressSpecificExtended:
- r := rt.(*bgp.IPv4AddressSpecificExtended)
return []bgp.ExtendedCommunityInterface{bgp.NewRedirectIPv4AddressSpecificExtended(r.IPv4.String(), r.LocalAdmin)}, nil
case *bgp.FourOctetAsSpecificExtended:
- r := rt.(*bgp.FourOctetAsSpecificExtended)
return []bgp.ExtendedCommunityInterface{bgp.NewRedirectFourOctetAsSpecificExtended(r.AS, r.LocalAdmin)}, nil
case *bgp.IPv6AddressSpecificExtended:
- r := rt.(*bgp.IPv6AddressSpecificExtended)
return []bgp.ExtendedCommunityInterface{bgp.NewRedirectIPv6AddressSpecificExtended(r.IPv6.String(), r.LocalAdmin)}, nil
}
return nil, fmt.Errorf("invalid redirect")
@@ -1241,7 +1237,7 @@ func parsePath(rf bgp.RouteFamily, args []string) (*api.Path, error) {
nlri = bgp.NewOpaqueNLRI([]byte(m["key"][0]), nil)
}
default:
- return nil, fmt.Errorf("Unsupported route family: %s", rf)
+ return nil, fmt.Errorf("unsupported route family: %s", rf)
}
if err != nil {
return nil, err
diff --git a/cmd/gobgp/mrt.go b/cmd/gobgp/mrt.go
index f03dd41e..61ce0a59 100644
--- a/cmd/gobgp/mrt.go
+++ b/cmd/gobgp/mrt.go
@@ -43,7 +43,7 @@ func injectMrt() error {
var idx int64
if mrtOpts.QueueSize < 1 {
- return fmt.Errorf("Specified queue size is smaller than 1, refusing to run with unbounded memory usage")
+ return fmt.Errorf("specified queue size is smaller than 1, refusing to run with unbounded memory usage")
}
ch := make(chan []*api.Path, mrtOpts.QueueSize)
@@ -112,7 +112,7 @@ func injectMrt() error {
for _, e := range rib.Entries {
if len(peers) < int(e.PeerIndex) {
- exitWithError(fmt.Errorf("invalid peer index: %d (PEER_INDEX_TABLE has only %d peers)\n", e.PeerIndex, len(peers)))
+ exitWithError(fmt.Errorf("invalid peer index: %d (PEER_INDEX_TABLE has only %d peers)", e.PeerIndex, len(peers)))
}
//t := time.Unix(int64(e.OriginatedTime), 0)
diff --git a/cmd/gobgp/neighbor.go b/cmd/gobgp/neighbor.go
index 31e01b4c..90d9e4f8 100644
--- a/cmd/gobgp/neighbor.go
+++ b/cmd/gobgp/neighbor.go
@@ -668,7 +668,7 @@ func showValidationInfo(p *api.Path, shownAs map[uint32]struct{}) error {
nlri, _ := apiutil.GetNativeNlri(p)
if len(asPath) == 0 {
- return fmt.Errorf("The path to %s was locally generated.\n", nlri.String())
+ return fmt.Errorf("the path to %s was locally generated", nlri.String())
} else if !checkOriginAsWasNotShown(p, asPath, shownAs) {
return nil
}
@@ -827,7 +827,7 @@ func showNeighborRib(r string, name string, args []string) error {
option = api.TableLookupOption_LOOKUP_SHORTER
} else if args[0] == "validation" {
if r != cmdAdjIn {
- return fmt.Errorf("RPKI information is supported for only adj-in.")
+ return fmt.Errorf("RPKI information is supported for only adj-in")
}
validationTarget = target
} else {
@@ -894,10 +894,10 @@ func showNeighborRib(r string, name string, args []string) error {
return err
}
if r == nil {
- return fmt.Errorf("Neighbor %v is not found", name)
+ return fmt.Errorf("neighbor %v is not found", name)
}
if r.Peer.State.SessionState != api.PeerState_ESTABLISHED {
- return fmt.Errorf("Neighbor %v's BGP session is not established", name)
+ return fmt.Errorf("neighbor %v's BGP session is not established", name)
}
}
}
@@ -986,7 +986,7 @@ func showNeighborRib(r string, name string, args []string) error {
func resetNeighbor(cmd string, remoteIP string, args []string) error {
if reasonLen := len(neighborsOpts.Reason); reasonLen > bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX {
- return fmt.Errorf("Too long reason for shutdown communication (max %d bytes)", bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX)
+ return fmt.Errorf("too long reason for shutdown communication (max %d bytes)", bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX)
}
var comm string
soft := true
@@ -1012,7 +1012,7 @@ func resetNeighbor(cmd string, remoteIP string, args []string) error {
func stateChangeNeighbor(cmd string, remoteIP string, args []string) error {
if reasonLen := len(neighborsOpts.Reason); reasonLen > bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX {
- return fmt.Errorf("Too long reason for shutdown communication (max %d bytes)", bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX)
+ return fmt.Errorf("too long reason for shutdown communication (max %d bytes)", bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX)
}
switch cmd {
case cmdShutdown:
diff --git a/cmd/gobgp/policy.go b/cmd/gobgp/policy.go
index d5fb80d3..8c720578 100644
--- a/cmd/gobgp/policy.go
+++ b/cmd/gobgp/policy.go
@@ -869,6 +869,7 @@ func modAction(name, op string, args []string) error {
}
typ := args[0]
args = args[1:]
+ cmd := "{ add | remove | replace } <value>..."
switch typ {
case "reject":
stmt.Actions.RouteAction = api.RouteAction_REJECT
@@ -877,7 +878,7 @@ func modAction(name, op string, args []string) error {
case "community":
stmt.Actions.Community = &api.CommunityAction{}
if len(args) < 1 {
- return fmt.Errorf("%s community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s community %s", usage, cmd)
}
stmt.Actions.Community.Communities = args[1:]
switch strings.ToLower(args[0]) {
@@ -888,12 +889,12 @@ func modAction(name, op string, args []string) error {
case "replace":
stmt.Actions.Community.ActionType = api.CommunityActionType_COMMUNITY_REPLACE
default:
- return fmt.Errorf("%s community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s community %s", usage, cmd)
}
case "ext-community":
stmt.Actions.ExtCommunity = &api.CommunityAction{}
if len(args) < 1 {
- return fmt.Errorf("%s ext-community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s ext-community %s", usage, cmd)
}
stmt.Actions.ExtCommunity.Communities = args[1:]
switch strings.ToLower(args[0]) {
@@ -904,12 +905,12 @@ func modAction(name, op string, args []string) error {
case "replace":
stmt.Actions.ExtCommunity.ActionType = api.CommunityActionType_COMMUNITY_REPLACE
default:
- return fmt.Errorf("%s ext-community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s ext-community %s", usage, cmd)
}
case "large-community":
stmt.Actions.LargeCommunity = &api.CommunityAction{}
if len(args) < 1 {
- return fmt.Errorf("%s large-community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s large-community %s", usage, cmd)
}
stmt.Actions.LargeCommunity.Communities = args[1:]
switch strings.ToLower(args[0]) {
@@ -920,7 +921,7 @@ func modAction(name, op string, args []string) error {
case "replace":
stmt.Actions.LargeCommunity.ActionType = api.CommunityActionType_COMMUNITY_REPLACE
default:
- return fmt.Errorf("%s large-community { add | remove | replace } <value>...", usage)
+ return fmt.Errorf("%s large-community %s", usage, cmd)
}
case "med":
stmt.Actions.Med = &api.MedAction{}
diff --git a/cmd/gobgp/vrf.go b/cmd/gobgp/vrf.go
index 69ec571e..73162519 100644
--- a/cmd/gobgp/vrf.go
+++ b/cmd/gobgp/vrf.go
@@ -127,7 +127,8 @@ func modVrf(typ string, args []string) error {
"rt": paramList,
"id": paramSingle})
if err != nil || len(a[""]) != 1 || len(a["rd"]) != 1 || len(a["rt"]) < 2 {
- return fmt.Errorf("Usage: gobgp vrf add <vrf name> [ id <id> ] rd <rd> rt { import | export | both } <rt>...")
+ //lint:ignore ST1005 cli example
+ return fmt.Errorf("usage: gobgp vrf add <vrf name> [ id <id> ] rd <rd> rt { import | export | both } <rt>...")
}
name := a[""][0]
var rd bgp.RouteDistinguisherInterface
@@ -156,7 +157,8 @@ func modVrf(typ string, args []string) error {
importRt = append(importRt, rt)
exportRt = append(exportRt, rt)
default:
- return fmt.Errorf("Usage: gobgp vrf add <vrf name> rd <rd> rt { import | export | both } <rt>...")
+ //lint:ignore ST1005 cli example
+ return fmt.Errorf("usage: gobgp vrf add <vrf name> [ id <id> ] rd <rd> rt { import | export | both } <rt>...")
}
}
var id uint64
@@ -178,7 +180,7 @@ func modVrf(typ string, args []string) error {
return err
case cmdDel:
if len(args) != 1 {
- return fmt.Errorf("Usage: gobgp vrf del <vrf name>")
+ return fmt.Errorf("usage: gobgp vrf del <vrf name>")
}
_, err := client.DeleteVrf(ctx, &api.DeleteVrfRequest{
Name: args[0],