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
0cf5a2de
Commit
0cf5a2de
authored
Oct 31, 2017
by
xiangpengzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Describe NetworkPolicyEgressRule.
parent
d735f660
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
describe.go
pkg/printers/internalversion/describe.go
+43
-0
No files found.
pkg/printers/internalversion/describe.go
View file @
0cf5a2de
...
...
@@ -3114,6 +3114,8 @@ func describeNetworkPolicySpec(nps networking.NetworkPolicySpec, w PrefixWriter)
}
w
.
Write
(
LEVEL_1
,
"Allowing ingress traffic:
\n
"
)
printNetworkPolicySpecIngressFrom
(
nps
.
Ingress
,
" "
,
w
)
w
.
Write
(
LEVEL_1
,
"Allowing egress traffic:
\n
"
)
printNetworkPolicySpecEgressTo
(
nps
.
Egress
,
" "
,
w
)
}
func
printNetworkPolicySpecIngressFrom
(
npirs
[]
networking
.
NetworkPolicyIngressRule
,
initialIndent
string
,
w
PrefixWriter
)
{
...
...
@@ -3157,6 +3159,47 @@ func printNetworkPolicySpecIngressFrom(npirs []networking.NetworkPolicyIngressRu
}
}
func
printNetworkPolicySpecEgressTo
(
npers
[]
networking
.
NetworkPolicyEgressRule
,
initialIndent
string
,
w
PrefixWriter
)
{
if
len
(
npers
)
==
0
{
w
.
Write
(
LEVEL_0
,
"%s%s
\n
"
,
initialIndent
,
"<none> (Selected pods are isolated for egress connectivity)"
)
return
}
for
i
,
nper
:=
range
npers
{
if
len
(
nper
.
Ports
)
==
0
{
w
.
Write
(
LEVEL_0
,
"%s%s
\n
"
,
initialIndent
,
"From Port: <any> (traffic allowed to all ports)"
)
}
else
{
for
_
,
port
:=
range
nper
.
Ports
{
var
proto
api
.
Protocol
if
port
.
Protocol
!=
nil
{
proto
=
*
port
.
Protocol
}
else
{
proto
=
api
.
ProtocolTCP
}
w
.
Write
(
LEVEL_0
,
"%s%s: %s/%s
\n
"
,
initialIndent
,
"From Port"
,
port
.
Port
,
proto
)
}
}
if
len
(
nper
.
To
)
==
0
{
w
.
Write
(
LEVEL_0
,
"%s%s
\n
"
,
initialIndent
,
"To: <any> (traffic not restricted by source)"
)
}
else
{
for
_
,
to
:=
range
nper
.
To
{
w
.
Write
(
LEVEL_0
,
"%s"
,
initialIndent
)
if
to
.
PodSelector
!=
nil
{
w
.
Write
(
LEVEL_0
,
"%s: %s
\n
"
,
"To Pod Selector"
,
metav1
.
FormatLabelSelector
(
to
.
PodSelector
))
}
else
if
to
.
NamespaceSelector
!=
nil
{
w
.
Write
(
LEVEL_0
,
"%s: %s
\n
"
,
"To Namespace Selector"
,
metav1
.
FormatLabelSelector
(
to
.
NamespaceSelector
))
}
else
if
to
.
IPBlock
!=
nil
{
w
.
Write
(
LEVEL_0
,
"To IPBlock:
\n
"
)
w
.
Write
(
LEVEL_0
,
"%s%sCIDR: %s
\n
"
,
initialIndent
,
initialIndent
,
to
.
IPBlock
.
CIDR
)
w
.
Write
(
LEVEL_0
,
"%s%sExcept: %v
\n
"
,
initialIndent
,
initialIndent
,
strings
.
Join
(
to
.
IPBlock
.
Except
,
", "
))
}
}
}
if
i
!=
len
(
npers
)
-
1
{
w
.
Write
(
LEVEL_0
,
"%s%s
\n
"
,
initialIndent
,
"----------"
)
}
}
}
type
StorageClassDescriber
struct
{
clientset
.
Interface
}
...
...
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