Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
028ac803
Commit
028ac803
authored
May 18, 2017
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove SaveAll from iptables interface
parent
151846db
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
83 deletions
+0
-83
fake_iptables.go
pkg/kubelet/network/hostport/fake_iptables.go
+0
-14
iptables.go
pkg/util/iptables/iptables.go
+0
-12
iptables_test.go
pkg/util/iptables/iptables_test.go
+0
-53
fake.go
pkg/util/iptables/testing/fake.go
+0
-4
No files found.
pkg/kubelet/network/hostport/fake_iptables.go
View file @
028ac803
...
@@ -246,20 +246,6 @@ func (f *fakeIPTables) Save(tableName utiliptables.Table) ([]byte, error) {
...
@@ -246,20 +246,6 @@ func (f *fakeIPTables) Save(tableName utiliptables.Table) ([]byte, error) {
return
data
.
Bytes
(),
nil
return
data
.
Bytes
(),
nil
}
}
func
(
f
*
fakeIPTables
)
SaveAll
()
([]
byte
,
error
)
{
data
:=
bytes
.
NewBuffer
(
nil
)
for
_
,
table
:=
range
f
.
tables
{
tableData
,
err
:=
f
.
Save
(
table
.
name
)
if
err
!=
nil
{
return
nil
,
err
}
if
_
,
err
=
data
.
Write
(
tableData
);
err
!=
nil
{
return
nil
,
err
}
}
return
data
.
Bytes
(),
nil
}
func
(
f
*
fakeIPTables
)
restore
(
restoreTableName
utiliptables
.
Table
,
data
[]
byte
,
flush
utiliptables
.
FlushFlag
)
error
{
func
(
f
*
fakeIPTables
)
restore
(
restoreTableName
utiliptables
.
Table
,
data
[]
byte
,
flush
utiliptables
.
FlushFlag
)
error
{
buf
:=
bytes
.
NewBuffer
(
data
)
buf
:=
bytes
.
NewBuffer
(
data
)
var
tableName
utiliptables
.
Table
var
tableName
utiliptables
.
Table
...
...
pkg/util/iptables/iptables.go
View file @
028ac803
...
@@ -56,8 +56,6 @@ type Interface interface {
...
@@ -56,8 +56,6 @@ type Interface interface {
IsIpv6
()
bool
IsIpv6
()
bool
// Save calls `iptables-save` for table.
// Save calls `iptables-save` for table.
Save
(
table
Table
)
([]
byte
,
error
)
Save
(
table
Table
)
([]
byte
,
error
)
// SaveAll calls `iptables-save`.
SaveAll
()
([]
byte
,
error
)
// Restore runs `iptables-restore` passing data through []byte.
// Restore runs `iptables-restore` passing data through []byte.
// table is the Table to restore
// table is the Table to restore
// data should be formatted like the output of Save()
// data should be formatted like the output of Save()
...
@@ -317,16 +315,6 @@ func (runner *runner) Save(table Table) ([]byte, error) {
...
@@ -317,16 +315,6 @@ func (runner *runner) Save(table Table) ([]byte, error) {
return
runner
.
exec
.
Command
(
cmdIPTablesSave
,
args
...
)
.
CombinedOutput
()
return
runner
.
exec
.
Command
(
cmdIPTablesSave
,
args
...
)
.
CombinedOutput
()
}
}
// SaveAll is part of Interface.
func
(
runner
*
runner
)
SaveAll
()
([]
byte
,
error
)
{
runner
.
mu
.
Lock
()
defer
runner
.
mu
.
Unlock
()
// run and return
glog
.
V
(
4
)
.
Infof
(
"running iptables-save"
)
return
runner
.
exec
.
Command
(
cmdIPTablesSave
,
[]
string
{}
...
)
.
CombinedOutput
()
}
// Restore is part of Interface.
// Restore is part of Interface.
func
(
runner
*
runner
)
Restore
(
table
Table
,
data
[]
byte
,
flush
FlushFlag
,
counters
RestoreCountersFlag
)
error
{
func
(
runner
*
runner
)
Restore
(
table
Table
,
data
[]
byte
,
flush
FlushFlag
,
counters
RestoreCountersFlag
)
error
{
// setup args
// setup args
...
...
pkg/util/iptables/iptables_test.go
View file @
028ac803
...
@@ -884,59 +884,6 @@ COMMIT
...
@@ -884,59 +884,6 @@ COMMIT
}
}
}
}
func
TestSaveAll
(
t
*
testing
.
T
)
{
output
:=
`# Generated by iptables-save v1.6.0 on Thu Jan 19 11:38:09 2017
*filter
:INPUT ACCEPT [15079:38410730]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [11045:521562]
COMMIT
# Completed on Thu Jan 19 11:38:09 2017`
fcmd
:=
exec
.
FakeCmd
{
CombinedOutputScript
:
[]
exec
.
FakeCombinedOutputAction
{
// iptables version check
func
()
([]
byte
,
error
)
{
return
[]
byte
(
"iptables v1.9.22"
),
nil
},
// iptables-restore version check
func
()
([]
byte
,
error
)
{
return
[]
byte
(
"iptables-restore v1.9.22"
),
nil
},
func
()
([]
byte
,
error
)
{
return
[]
byte
(
output
),
nil
},
func
()
([]
byte
,
error
)
{
return
nil
,
&
exec
.
FakeExitError
{
Status
:
1
}
},
},
}
fexec
:=
exec
.
FakeExec
{
CommandScript
:
[]
exec
.
FakeCommandAction
{
func
(
cmd
string
,
args
...
string
)
exec
.
Cmd
{
return
exec
.
InitFakeCmd
(
&
fcmd
,
cmd
,
args
...
)
},
func
(
cmd
string
,
args
...
string
)
exec
.
Cmd
{
return
exec
.
InitFakeCmd
(
&
fcmd
,
cmd
,
args
...
)
},
func
(
cmd
string
,
args
...
string
)
exec
.
Cmd
{
return
exec
.
InitFakeCmd
(
&
fcmd
,
cmd
,
args
...
)
},
func
(
cmd
string
,
args
...
string
)
exec
.
Cmd
{
return
exec
.
InitFakeCmd
(
&
fcmd
,
cmd
,
args
...
)
},
},
}
runner
:=
New
(
&
fexec
,
dbus
.
NewFake
(
nil
,
nil
),
ProtocolIpv4
)
defer
runner
.
Destroy
()
// Success.
o
,
err
:=
runner
.
SaveAll
()
if
err
!=
nil
{
t
.
Fatalf
(
"expected success, got %v"
,
err
)
}
if
string
(
o
[
:
len
(
output
)])
!=
output
{
t
.
Errorf
(
"expected output to be equal to mocked one, got %v"
,
o
)
}
if
fcmd
.
CombinedOutputCalls
!=
3
{
t
.
Errorf
(
"expected 3 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
2
]
...
)
.
HasAll
(
"iptables-save"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
2
])
}
// Failure.
_
,
err
=
runner
.
SaveAll
()
if
err
==
nil
{
t
.
Errorf
(
"expected failure"
)
}
}
func
TestRestore
(
t
*
testing
.
T
)
{
func
TestRestore
(
t
*
testing
.
T
)
{
fcmd
:=
exec
.
FakeCmd
{
fcmd
:=
exec
.
FakeCmd
{
CombinedOutputScript
:
[]
exec
.
FakeCombinedOutputAction
{
CombinedOutputScript
:
[]
exec
.
FakeCombinedOutputAction
{
...
...
pkg/util/iptables/testing/fake.go
View file @
028ac803
...
@@ -78,10 +78,6 @@ func (f *FakeIPTables) Save(table iptables.Table) ([]byte, error) {
...
@@ -78,10 +78,6 @@ func (f *FakeIPTables) Save(table iptables.Table) ([]byte, error) {
return
lines
,
nil
return
lines
,
nil
}
}
func
(
*
FakeIPTables
)
SaveAll
()
([]
byte
,
error
)
{
return
make
([]
byte
,
0
),
nil
}
func
(
*
FakeIPTables
)
Restore
(
table
iptables
.
Table
,
data
[]
byte
,
flush
iptables
.
FlushFlag
,
counters
iptables
.
RestoreCountersFlag
)
error
{
func
(
*
FakeIPTables
)
Restore
(
table
iptables
.
Table
,
data
[]
byte
,
flush
iptables
.
FlushFlag
,
counters
iptables
.
RestoreCountersFlag
)
error
{
return
nil
return
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment