@@ -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-
3426func (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}
0 commit comments