Skip to content

Commit 78d28b3

Browse files
QxBytestamilmani1989
authored andcommitted
address linter issues
1 parent 6005f9e commit 78d28b3

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

cns/fakes/iptablesfake.go

+5-13
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

+4-4
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

cns/restserver/internalapi_windows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var errUnsupportedAPI = errors.New("unsupported api")
2020

2121
type IPtablesProvider struct{}
2222

23-
func (_ *IPtablesProvider) GetIPTables() (iptablesClient, error) {
23+
func (*IPtablesProvider) GetIPTables() (iptablesClient, error) {
2424
return nil, errUnsupportedAPI
2525
}
2626

0 commit comments

Comments
 (0)