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
bcdff4f1
Commit
bcdff4f1
authored
Nov 03, 2017
by
xiangpengzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix wrong format and output.
parent
3921ac9d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
14 deletions
+19
-14
describe.go
pkg/printers/internalversion/describe.go
+15
-10
describe_test.go
pkg/printers/internalversion/describe_test.go
+4
-4
No files found.
pkg/printers/internalversion/describe.go
View file @
bcdff4f1
...
@@ -3116,7 +3116,7 @@ func describeNetworkPolicySpec(nps networking.NetworkPolicySpec, w PrefixWriter)
...
@@ -3116,7 +3116,7 @@ func describeNetworkPolicySpec(nps networking.NetworkPolicySpec, w PrefixWriter)
printNetworkPolicySpecIngressFrom
(
nps
.
Ingress
,
" "
,
w
)
printNetworkPolicySpecIngressFrom
(
nps
.
Ingress
,
" "
,
w
)
w
.
Write
(
LEVEL_1
,
"Allowing egress traffic:
\n
"
)
w
.
Write
(
LEVEL_1
,
"Allowing egress traffic:
\n
"
)
printNetworkPolicySpecEgressTo
(
nps
.
Egress
,
" "
,
w
)
printNetworkPolicySpecEgressTo
(
nps
.
Egress
,
" "
,
w
)
w
.
Write
(
LEVEL_1
,
"Policy Types: %v
\n
"
,
nps
.
PolicyTypes
)
w
.
Write
(
LEVEL_1
,
"Policy Types: %v
\n
"
,
policyTypesToString
(
nps
.
PolicyTypes
)
)
}
}
func
printNetworkPolicySpecIngressFrom
(
npirs
[]
networking
.
NetworkPolicyIngressRule
,
initialIndent
string
,
w
PrefixWriter
)
{
func
printNetworkPolicySpecIngressFrom
(
npirs
[]
networking
.
NetworkPolicyIngressRule
,
initialIndent
string
,
w
PrefixWriter
)
{
...
@@ -3167,7 +3167,7 @@ func printNetworkPolicySpecEgressTo(npers []networking.NetworkPolicyEgressRule,
...
@@ -3167,7 +3167,7 @@ func printNetworkPolicySpecEgressTo(npers []networking.NetworkPolicyEgressRule,
}
}
for
i
,
nper
:=
range
npers
{
for
i
,
nper
:=
range
npers
{
if
len
(
nper
.
Ports
)
==
0
{
if
len
(
nper
.
Ports
)
==
0
{
w
.
Write
(
LEVEL_0
,
"%s%s
\n
"
,
initialIndent
,
"
From
Port: <any> (traffic allowed to all ports)"
)
w
.
Write
(
LEVEL_0
,
"%s%s
\n
"
,
initialIndent
,
"
To
Port: <any> (traffic allowed to all ports)"
)
}
else
{
}
else
{
for
_
,
port
:=
range
nper
.
Ports
{
for
_
,
port
:=
range
nper
.
Ports
{
var
proto
api
.
Protocol
var
proto
api
.
Protocol
...
@@ -3176,7 +3176,7 @@ func printNetworkPolicySpecEgressTo(npers []networking.NetworkPolicyEgressRule,
...
@@ -3176,7 +3176,7 @@ func printNetworkPolicySpecEgressTo(npers []networking.NetworkPolicyEgressRule,
}
else
{
}
else
{
proto
=
api
.
ProtocolTCP
proto
=
api
.
ProtocolTCP
}
}
w
.
Write
(
LEVEL_0
,
"%s%s: %s/%s
\n
"
,
initialIndent
,
"
From
Port"
,
port
.
Port
,
proto
)
w
.
Write
(
LEVEL_0
,
"%s%s: %s/%s
\n
"
,
initialIndent
,
"
To
Port"
,
port
.
Port
,
proto
)
}
}
}
}
if
len
(
nper
.
To
)
==
0
{
if
len
(
nper
.
To
)
==
0
{
...
@@ -3381,13 +3381,6 @@ func describePodSecurityPolicy(psp *extensions.PodSecurityPolicy) (string, error
...
@@ -3381,13 +3381,6 @@ func describePodSecurityPolicy(psp *extensions.PodSecurityPolicy) (string, error
})
})
}
}
func
stringOrAll
(
s
string
)
string
{
if
len
(
s
)
>
0
{
return
s
}
return
"*"
}
func
stringOrNone
(
s
string
)
string
{
func
stringOrNone
(
s
string
)
string
{
if
len
(
s
)
>
0
{
if
len
(
s
)
>
0
{
return
s
return
s
...
@@ -3451,6 +3444,18 @@ func capsToString(caps []api.Capability) string {
...
@@ -3451,6 +3444,18 @@ func capsToString(caps []api.Capability) string {
return
stringOrNone
(
formattedString
)
return
stringOrNone
(
formattedString
)
}
}
func
policyTypesToString
(
pts
[]
networking
.
PolicyType
)
string
{
formattedString
:=
""
if
pts
!=
nil
{
strPts
:=
[]
string
{}
for
_
,
p
:=
range
pts
{
strPts
=
append
(
strPts
,
string
(
p
))
}
formattedString
=
strings
.
Join
(
strPts
,
", "
)
}
return
stringOrNone
(
formattedString
)
}
// newErrNoDescriber creates a new ErrNoDescriber with the names of the provided types.
// newErrNoDescriber creates a new ErrNoDescriber with the names of the provided types.
func
newErrNoDescriber
(
types
...
reflect
.
Type
)
error
{
func
newErrNoDescriber
(
types
...
reflect
.
Type
)
error
{
names
:=
make
([]
string
,
0
,
len
(
types
))
names
:=
make
([]
string
,
0
,
len
(
types
))
...
...
pkg/printers/internalversion/describe_test.go
View file @
bcdff4f1
...
@@ -1671,8 +1671,8 @@ Spec:
...
@@ -1671,8 +1671,8 @@ Spec:
To Port: <any> (traffic allowed to all ports)
To Port: <any> (traffic allowed to all ports)
From: <any> (traffic not restricted by source)
From: <any> (traffic not restricted by source)
Allowing egress traffic:
Allowing egress traffic:
From
Port: 80/TCP
To
Port: 80/TCP
From
Port: 82/TCP
To
Port: 82/TCP
To Pod Selector: id=app2,id2=app3
To Pod Selector: id=app2,id2=app3
To Namespace Selector: id=app2,id2=app3
To Namespace Selector: id=app2,id2=app3
To Namespace Selector: foo in (bar1,bar2),id=app2,id2=app3
To Namespace Selector: foo in (bar1,bar2),id=app2,id2=app3
...
@@ -1680,9 +1680,9 @@ Spec:
...
@@ -1680,9 +1680,9 @@ Spec:
CIDR: 192.168.0.0/16
CIDR: 192.168.0.0/16
Except: 192.168.3.0/24, 192.168.4.0/24
Except: 192.168.3.0/24, 192.168.4.0/24
----------
----------
From
Port: <any> (traffic allowed to all ports)
To
Port: <any> (traffic allowed to all ports)
To: <any> (traffic not restricted by source)
To: <any> (traffic not restricted by source)
Policy Types:
[Ingress Egress]
Policy Types:
Ingress, Egress
`
`
port80
:=
intstr
.
FromInt
(
80
)
port80
:=
intstr
.
FromInt
(
80
)
...
...
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