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
241f30b9
Commit
241f30b9
authored
Jul 28, 2017
by
Haoran Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add table printer for psp
parent
c4fc7168
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
16 deletions
+31
-16
BUILD
pkg/printers/internalversion/BUILD
+1
-0
printers.go
pkg/printers/internalversion/printers.go
+30
-16
No files found.
pkg/printers/internalversion/BUILD
View file @
241f30b9
...
...
@@ -91,6 +91,7 @@ go_library(
"//vendor/github.com/fatih/camelcase:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
"//vendor/k8s.io/api/autoscaling/v2alpha1:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v2alpha1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
...
...
pkg/printers/internalversion/printers.go
View file @
241f30b9
...
...
@@ -68,7 +68,6 @@ var (
clusterRoleBindingWideColumns
=
[]
string
{
"ROLE"
,
"USERS"
,
"GROUPS"
,
"SERVICEACCOUNTS"
}
storageClassColumns
=
[]
string
{
"NAME"
,
"PROVISIONER"
}
statusColumns
=
[]
string
{
"STATUS"
,
"REASON"
,
"MESSAGE"
}
podSecurityPolicyColumns
=
[]
string
{
"NAME"
,
"PRIV"
,
"CAPS"
,
"SELINUX"
,
"RUNASUSER"
,
"FSGROUP"
,
"SUPGROUP"
,
"READONLYROOTFS"
,
"VOLUMES"
}
clusterColumns
=
[]
string
{
"NAME"
,
"STATUS"
,
"AGE"
}
networkPolicyColumns
=
[]
string
{
"NAME"
,
"POD-SELECTOR"
,
"AGE"
}
certificateSigningRequestColumns
=
[]
string
{
"NAME"
,
"AGE"
,
"REQUESTOR"
,
"CONDITION"
}
...
...
@@ -350,8 +349,20 @@ func AddHandlers(h printers.PrintHandler) {
}
h
.
TableHandler
(
configMapColumnDefinitions
,
printConfigMap
)
h
.
TableHandler
(
configMapColumnDefinitions
,
printConfigMapList
)
h
.
Handler
(
podSecurityPolicyColumns
,
nil
,
printPodSecurityPolicy
)
h
.
Handler
(
podSecurityPolicyColumns
,
nil
,
printPodSecurityPolicyList
)
podSecurityPolicyColumnDefinitions
:=
[]
metav1alpha1
.
TableColumnDefinition
{
{
Name
:
"Name"
,
Type
:
"string"
,
Format
:
"name"
,
Description
:
metav1
.
ObjectMeta
{}
.
SwaggerDoc
()[
"name"
]},
{
Name
:
"Data"
,
Type
:
"string"
,
Description
:
extensionsv1beta1
.
PodSecurityPolicySpec
{}
.
SwaggerDoc
()[
"privileged"
]},
{
Name
:
"Caps"
,
Type
:
"string"
,
Description
:
extensionsv1beta1
.
PodSecurityPolicySpec
{}
.
SwaggerDoc
()[
"allowedCapabilities"
]},
{
Name
:
"Selinux"
,
Type
:
"string"
,
Description
:
extensionsv1beta1
.
PodSecurityPolicySpec
{}
.
SwaggerDoc
()[
"seLinux"
]},
{
Name
:
"RunAsUser"
,
Type
:
"string"
,
Description
:
extensionsv1beta1
.
PodSecurityPolicySpec
{}
.
SwaggerDoc
()[
"runAsUser"
]},
{
Name
:
"FsGroup"
,
Type
:
"string"
,
Description
:
extensionsv1beta1
.
PodSecurityPolicySpec
{}
.
SwaggerDoc
()[
"fsGroup"
]},
{
Name
:
"SupGroup"
,
Type
:
"string"
,
Description
:
extensionsv1beta1
.
PodSecurityPolicySpec
{}
.
SwaggerDoc
()[
"supplementalGroups"
]},
{
Name
:
"ReadOnlyRootFs"
,
Type
:
"string"
,
Description
:
extensionsv1beta1
.
PodSecurityPolicySpec
{}
.
SwaggerDoc
()[
"readOnlyRootFilesystem"
]},
{
Name
:
"Volumes"
,
Type
:
"string"
,
Description
:
extensionsv1beta1
.
PodSecurityPolicySpec
{}
.
SwaggerDoc
()[
"volumes"
]},
}
h
.
TableHandler
(
podSecurityPolicyColumnDefinitions
,
printPodSecurityPolicy
)
h
.
TableHandler
(
podSecurityPolicyColumnDefinitions
,
printPodSecurityPolicyList
)
h
.
Handler
(
clusterColumns
,
nil
,
printCluster
)
h
.
Handler
(
clusterColumns
,
nil
,
printClusterList
)
h
.
Handler
(
networkPolicyColumns
,
nil
,
printExtensionsNetworkPolicy
)
...
...
@@ -1617,23 +1628,26 @@ func printConfigMapList(list *api.ConfigMapList, options printers.PrintOptions)
return
rows
,
nil
}
func
printPodSecurityPolicy
(
item
*
extensions
.
PodSecurityPolicy
,
w
io
.
Writer
,
options
printers
.
PrintOptions
)
error
{
name
:=
printers
.
FormatResourceName
(
options
.
Kind
,
item
.
Name
,
options
.
WithKind
)
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%t
\t
%v
\t
%s
\t
%s
\t
%s
\t
%s
\t
%t
\t
%v
\n
"
,
name
,
item
.
Spec
.
Privileged
,
item
.
Spec
.
AllowedCapabilities
,
item
.
Spec
.
SELinux
.
Rule
,
item
.
Spec
.
RunAsUser
.
Rule
,
item
.
Spec
.
FSGroup
.
Rule
,
item
.
Spec
.
SupplementalGroups
.
Rule
,
item
.
Spec
.
ReadOnlyRootFilesystem
,
item
.
Spec
.
Volumes
)
return
err
func
printPodSecurityPolicy
(
obj
*
extensions
.
PodSecurityPolicy
,
options
printers
.
PrintOptions
)
([]
metav1alpha1
.
TableRow
,
error
)
{
row
:=
metav1alpha1
.
TableRow
{
Object
:
runtime
.
RawExtension
{
Object
:
obj
},
}
row
.
Cells
=
append
(
row
.
Cells
,
obj
.
Name
,
obj
.
Spec
.
Privileged
,
obj
.
Spec
.
AllowedCapabilities
,
obj
.
Spec
.
SELinux
.
Rule
,
obj
.
Spec
.
RunAsUser
.
Rule
,
obj
.
Spec
.
FSGroup
.
Rule
,
obj
.
Spec
.
SupplementalGroups
.
Rule
,
obj
.
Spec
.
ReadOnlyRootFilesystem
,
obj
.
Spec
.
Volumes
)
return
[]
metav1alpha1
.
TableRow
{
row
},
nil
}
func
printPodSecurityPolicyList
(
list
*
extensions
.
PodSecurityPolicyList
,
w
io
.
Writer
,
options
printers
.
PrintOptions
)
error
{
for
_
,
item
:=
range
list
.
Items
{
if
err
:=
printPodSecurityPolicy
(
&
item
,
w
,
options
);
err
!=
nil
{
return
err
func
printPodSecurityPolicyList
(
list
*
extensions
.
PodSecurityPolicyList
,
options
printers
.
PrintOptions
)
([]
metav1alpha1
.
TableRow
,
error
)
{
rows
:=
make
([]
metav1alpha1
.
TableRow
,
0
,
len
(
list
.
Items
))
for
i
:=
range
list
.
Items
{
r
,
err
:=
printPodSecurityPolicy
(
&
list
.
Items
[
i
],
options
)
if
err
!=
nil
{
return
nil
,
err
}
rows
=
append
(
rows
,
r
...
)
}
return
nil
return
rows
,
nil
}
func
printExtensionsNetworkPolicy
(
networkPolicy
*
extensions
.
NetworkPolicy
,
w
io
.
Writer
,
options
printers
.
PrintOptions
)
error
{
...
...
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