Skip to content

Commit 3dcb726

Browse files
committed
address linter issues
1 parent 158dda6 commit 3dcb726

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

cns/fakes/iptablesfake.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ func NewIPTablesMock() *IPTablesMock {
2323
}
2424
}
2525

26-
type iptablesClient interface {
27-
ChainExists(table string, chain string) (bool, error)
28-
NewChain(table string, chain string) error
29-
Exists(table string, chain string, rulespec ...string) (bool, error)
30-
Append(table string, chain string, rulespec ...string) error
31-
Insert(table string, chain string, pos int, rulespec ...string) error
32-
}
33-
3426
func (c *IPTablesMock) ensureTableExists(table string) {
3527
_, exists := c.state[table]
3628
if !exists {
@@ -69,15 +61,15 @@ func (c *IPTablesMock) NewChain(table, chain string) error {
6961
return nil
7062
}
7163

72-
func (c *IPTablesMock) Exists(table string, chain string, rulespec ...string) (bool, error) {
64+
func (c *IPTablesMock) Exists(table, chain string, rulespec ...string) (bool, error) {
7365
c.ensureTableExists(table)
7466

7567
chainExists, _ := c.ChainExists(table, chain)
7668
if !chainExists {
7769
return false, nil
7870
}
7971

80-
targetRule := strings.Join(rulespec[:], " ")
72+
targetRule := strings.Join(rulespec, " ")
8173
chainRules := c.state[table][chain]
8274

8375
for _, chainRule := range chainRules {
@@ -88,7 +80,7 @@ func (c *IPTablesMock) Exists(table string, chain string, rulespec ...string) (b
8880
return false, nil
8981
}
9082

91-
func (c *IPTablesMock) Append(table string, chain string, rulespec ...string) error {
83+
func (c *IPTablesMock) Append(table, chain string, rulespec ...string) error {
9284
c.ensureTableExists(table)
9385

9486
chainExists, _ := c.ChainExists(table, chain)
@@ -101,11 +93,11 @@ func (c *IPTablesMock) Append(table string, chain string, rulespec ...string) er
10193
return errRuleExists
10294
}
10395

104-
targetRule := strings.Join(rulespec[:], " ")
96+
targetRule := strings.Join(rulespec, " ")
10597
c.state[table][chain] = append(c.state[table][chain], targetRule)
10698
return nil
10799
}
108100

109-
func (c *IPTablesMock) Insert(table string, chain string, _ int, rulespec ...string) error {
101+
func (c *IPTablesMock) Insert(table, chain string, _ int, rulespec ...string) error {
110102
return c.Append(table, chain, rulespec...)
111103
}

cns/restserver/internalapi_linux.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ import (
1111
"github.com/Azure/azure-container-networking/iptables"
1212
"github.com/Azure/azure-container-networking/network/networkutils"
1313
goiptables "github.com/coreos/go-iptables/iptables"
14+
"github.com/pkg/errors"
1415
)
1516

1617
const SWIFT = "SWIFT-POSTROUTING"
1718

18-
type IPtablesProvider struct {
19-
iptc iptablesClient
20-
}
19+
type IPtablesProvider struct{}
2120

2221
func (c *IPtablesProvider) GetIPTables() (iptablesClient, error) {
23-
return goiptables.New()
22+
client, err := goiptables.New()
23+
return client, errors.Wrap(err, "failed to get iptables client")
2424
}
2525

2626
// nolint

0 commit comments

Comments
 (0)