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
36987e9d
Commit
36987e9d
authored
Aug 16, 2015
by
hurf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move formatLabels function to labels package
As the TODO above the function instructed, move formatLables function to labels package.
parent
5fe7029e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
29 deletions
+29
-29
describe.go
pkg/kubectl/describe.go
+12
-12
kubectl.go
pkg/kubectl/kubectl.go
+0
-10
resource_printer.go
pkg/kubectl/resource_printer.go
+8
-7
labels.go
pkg/labels/labels.go
+9
-0
No files found.
pkg/kubectl/describe.go
View file @
36987e9d
...
@@ -155,7 +155,7 @@ func (d *NamespaceDescriber) Describe(namespace, name string) (string, error) {
...
@@ -155,7 +155,7 @@ func (d *NamespaceDescriber) Describe(namespace, name string) (string, error) {
func
describeNamespace
(
namespace
*
api
.
Namespace
,
resourceQuotaList
*
api
.
ResourceQuotaList
,
limitRangeList
*
api
.
LimitRangeList
)
(
string
,
error
)
{
func
describeNamespace
(
namespace
*
api
.
Namespace
,
resourceQuotaList
*
api
.
ResourceQuotaList
,
limitRangeList
*
api
.
LimitRangeList
)
(
string
,
error
)
{
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
namespace
.
Name
)
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
namespace
.
Name
)
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
f
ormatLabels
(
namespace
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
F
ormatLabels
(
namespace
.
Labels
))
fmt
.
Fprintf
(
out
,
"Status:
\t
%s
\n
"
,
string
(
namespace
.
Status
.
Phase
))
fmt
.
Fprintf
(
out
,
"Status:
\t
%s
\n
"
,
string
(
namespace
.
Status
.
Phase
))
if
resourceQuotaList
!=
nil
{
if
resourceQuotaList
!=
nil
{
fmt
.
Fprintf
(
out
,
"
\n
"
)
fmt
.
Fprintf
(
out
,
"
\n
"
)
...
@@ -416,7 +416,7 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
...
@@ -416,7 +416,7 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
pod
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
pod
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Image(s):
\t
%s
\n
"
,
makeImageList
(
&
pod
.
Spec
))
fmt
.
Fprintf
(
out
,
"Image(s):
\t
%s
\n
"
,
makeImageList
(
&
pod
.
Spec
))
fmt
.
Fprintf
(
out
,
"Node:
\t
%s
\n
"
,
pod
.
Spec
.
NodeName
+
"/"
+
pod
.
Status
.
HostIP
)
fmt
.
Fprintf
(
out
,
"Node:
\t
%s
\n
"
,
pod
.
Spec
.
NodeName
+
"/"
+
pod
.
Status
.
HostIP
)
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
f
ormatLabels
(
pod
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
F
ormatLabels
(
pod
.
Labels
))
if
pod
.
DeletionTimestamp
!=
nil
{
if
pod
.
DeletionTimestamp
!=
nil
{
fmt
.
Fprintf
(
out
,
"Status:
\t
Terminating (expires %s)
\n
"
,
pod
.
DeletionTimestamp
.
Time
.
Format
(
time
.
RFC1123Z
))
fmt
.
Fprintf
(
out
,
"Status:
\t
Terminating (expires %s)
\n
"
,
pod
.
DeletionTimestamp
.
Time
.
Format
(
time
.
RFC1123Z
))
fmt
.
Fprintf
(
out
,
"Termination Grace Period:
\t
%ds
\n
"
,
pod
.
DeletionGracePeriodSeconds
)
fmt
.
Fprintf
(
out
,
"Termination Grace Period:
\t
%ds
\n
"
,
pod
.
DeletionGracePeriodSeconds
)
...
@@ -584,7 +584,7 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string) (string, er
...
@@ -584,7 +584,7 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string) (string, er
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
pv
.
Name
)
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
pv
.
Name
)
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
f
ormatLabels
(
pv
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
F
ormatLabels
(
pv
.
Labels
))
fmt
.
Fprintf
(
out
,
"Status:
\t
%s
\n
"
,
pv
.
Status
.
Phase
)
fmt
.
Fprintf
(
out
,
"Status:
\t
%s
\n
"
,
pv
.
Status
.
Phase
)
if
pv
.
Spec
.
ClaimRef
!=
nil
{
if
pv
.
Spec
.
ClaimRef
!=
nil
{
fmt
.
Fprintf
(
out
,
"Claim:
\t
%s
\n
"
,
pv
.
Spec
.
ClaimRef
.
Namespace
+
"/"
+
pv
.
Spec
.
ClaimRef
.
Name
)
fmt
.
Fprintf
(
out
,
"Claim:
\t
%s
\n
"
,
pv
.
Spec
.
ClaimRef
.
Namespace
+
"/"
+
pv
.
Spec
.
ClaimRef
.
Name
)
...
@@ -611,7 +611,7 @@ func (d *PersistentVolumeClaimDescriber) Describe(namespace, name string) (strin
...
@@ -611,7 +611,7 @@ func (d *PersistentVolumeClaimDescriber) Describe(namespace, name string) (strin
return
""
,
err
return
""
,
err
}
}
labels
:=
f
ormatLabels
(
pvc
.
Labels
)
labels
:=
labels
.
F
ormatLabels
(
pvc
.
Labels
)
storage
:=
pvc
.
Spec
.
Resources
.
Requests
[
api
.
ResourceStorage
]
storage
:=
pvc
.
Spec
.
Resources
.
Requests
[
api
.
ResourceStorage
]
capacity
:=
""
capacity
:=
""
accessModes
:=
""
accessModes
:=
""
...
@@ -756,8 +756,8 @@ func describeReplicationController(controller *api.ReplicationController, events
...
@@ -756,8 +756,8 @@ func describeReplicationController(controller *api.ReplicationController, events
}
else
{
}
else
{
fmt
.
Fprintf
(
out
,
"Image(s):
\t
%s
\n
"
,
"<no template>"
)
fmt
.
Fprintf
(
out
,
"Image(s):
\t
%s
\n
"
,
"<no template>"
)
}
}
fmt
.
Fprintf
(
out
,
"Selector:
\t
%s
\n
"
,
f
ormatLabels
(
controller
.
Spec
.
Selector
))
fmt
.
Fprintf
(
out
,
"Selector:
\t
%s
\n
"
,
labels
.
F
ormatLabels
(
controller
.
Spec
.
Selector
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
f
ormatLabels
(
controller
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
F
ormatLabels
(
controller
.
Labels
))
fmt
.
Fprintf
(
out
,
"Replicas:
\t
%d current / %d desired
\n
"
,
controller
.
Status
.
Replicas
,
controller
.
Spec
.
Replicas
)
fmt
.
Fprintf
(
out
,
"Replicas:
\t
%d current / %d desired
\n
"
,
controller
.
Status
.
Replicas
,
controller
.
Spec
.
Replicas
)
fmt
.
Fprintf
(
out
,
"Pods Status:
\t
%d Running / %d Waiting / %d Succeeded / %d Failed
\n
"
,
running
,
waiting
,
succeeded
,
failed
)
fmt
.
Fprintf
(
out
,
"Pods Status:
\t
%d Running / %d Waiting / %d Succeeded / %d Failed
\n
"
,
running
,
waiting
,
succeeded
,
failed
)
if
controller
.
Spec
.
Template
!=
nil
{
if
controller
.
Spec
.
Template
!=
nil
{
...
@@ -790,8 +790,8 @@ func describeSecret(secret *api.Secret) (string, error) {
...
@@ -790,8 +790,8 @@ func describeSecret(secret *api.Secret) (string, error) {
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
secret
.
Name
)
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
secret
.
Name
)
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
secret
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
secret
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
f
ormatLabels
(
secret
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
F
ormatLabels
(
secret
.
Labels
))
fmt
.
Fprintf
(
out
,
"Annotations:
\t
%s
\n
"
,
f
ormatLabels
(
secret
.
Annotations
))
fmt
.
Fprintf
(
out
,
"Annotations:
\t
%s
\n
"
,
labels
.
F
ormatLabels
(
secret
.
Annotations
))
fmt
.
Fprintf
(
out
,
"
\n
Type:
\t
%s
\n
"
,
secret
.
Type
)
fmt
.
Fprintf
(
out
,
"
\n
Type:
\t
%s
\n
"
,
secret
.
Type
)
...
@@ -851,8 +851,8 @@ func describeService(service *api.Service, endpoints *api.Endpoints, events *api
...
@@ -851,8 +851,8 @@ func describeService(service *api.Service, endpoints *api.Endpoints, events *api
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
service
.
Name
)
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
service
.
Name
)
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
service
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
service
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
f
ormatLabels
(
service
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
F
ormatLabels
(
service
.
Labels
))
fmt
.
Fprintf
(
out
,
"Selector:
\t
%s
\n
"
,
f
ormatLabels
(
service
.
Spec
.
Selector
))
fmt
.
Fprintf
(
out
,
"Selector:
\t
%s
\n
"
,
labels
.
F
ormatLabels
(
service
.
Spec
.
Selector
))
fmt
.
Fprintf
(
out
,
"Type:
\t
%s
\n
"
,
service
.
Spec
.
Type
)
fmt
.
Fprintf
(
out
,
"Type:
\t
%s
\n
"
,
service
.
Spec
.
Type
)
fmt
.
Fprintf
(
out
,
"IP:
\t
%s
\n
"
,
service
.
Spec
.
ClusterIP
)
fmt
.
Fprintf
(
out
,
"IP:
\t
%s
\n
"
,
service
.
Spec
.
ClusterIP
)
if
len
(
service
.
Status
.
LoadBalancer
.
Ingress
)
>
0
{
if
len
(
service
.
Status
.
LoadBalancer
.
Ingress
)
>
0
{
...
@@ -914,7 +914,7 @@ func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Sec
...
@@ -914,7 +914,7 @@ func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Sec
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
serviceAccount
.
Name
)
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
serviceAccount
.
Name
)
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
serviceAccount
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
serviceAccount
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
f
ormatLabels
(
serviceAccount
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
F
ormatLabels
(
serviceAccount
.
Labels
))
fmt
.
Fprintln
(
out
)
fmt
.
Fprintln
(
out
)
var
(
var
(
...
@@ -1000,7 +1000,7 @@ func (d *NodeDescriber) Describe(namespace, name string) (string, error) {
...
@@ -1000,7 +1000,7 @@ func (d *NodeDescriber) Describe(namespace, name string) (string, error) {
func
describeNode
(
node
*
api
.
Node
,
pods
[]
*
api
.
Pod
,
events
*
api
.
EventList
)
(
string
,
error
)
{
func
describeNode
(
node
*
api
.
Node
,
pods
[]
*
api
.
Pod
,
events
*
api
.
EventList
)
(
string
,
error
)
{
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
node
.
Name
)
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
node
.
Name
)
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
f
ormatLabels
(
node
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
F
ormatLabels
(
node
.
Labels
))
fmt
.
Fprintf
(
out
,
"CreationTimestamp:
\t
%s
\n
"
,
node
.
CreationTimestamp
.
Time
.
Format
(
time
.
RFC1123Z
))
fmt
.
Fprintf
(
out
,
"CreationTimestamp:
\t
%s
\n
"
,
node
.
CreationTimestamp
.
Time
.
Format
(
time
.
RFC1123Z
))
if
len
(
node
.
Status
.
Conditions
)
>
0
{
if
len
(
node
.
Status
.
Conditions
)
>
0
{
fmt
.
Fprint
(
out
,
"Conditions:
\n
Type
\t
Status
\t
LastHeartbeatTime
\t
LastTransitionTime
\t
Reason
\t
Message
\n
"
)
fmt
.
Fprint
(
out
,
"Conditions:
\n
Type
\t
Status
\t
LastHeartbeatTime
\t
LastTransitionTime
\t
Reason
\t
Message
\n
"
)
...
...
pkg/kubectl/kubectl.go
View file @
36987e9d
...
@@ -23,7 +23,6 @@ import (
...
@@ -23,7 +23,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/labels"
)
)
const
kubectlAnnotationPrefix
=
"kubectl.kubernetes.io/"
const
kubectlAnnotationPrefix
=
"kubectl.kubernetes.io/"
...
@@ -32,15 +31,6 @@ type NamespaceInfo struct {
...
@@ -32,15 +31,6 @@ type NamespaceInfo struct {
Namespace
string
Namespace
string
}
}
// TODO Move to labels package.
func
formatLabels
(
labelMap
map
[
string
]
string
)
string
{
l
:=
labels
.
Set
(
labelMap
)
.
String
()
if
l
==
""
{
l
=
"<none>"
}
return
l
}
func
listOfImages
(
spec
*
api
.
PodSpec
)
[]
string
{
func
listOfImages
(
spec
*
api
.
PodSpec
)
[]
string
{
var
images
[]
string
var
images
[]
string
for
_
,
container
:=
range
spec
.
Containers
{
for
_
,
container
:=
range
spec
.
Containers
{
...
...
pkg/kubectl/resource_printer.go
View file @
36987e9d
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/conversion"
"k8s.io/kubernetes/pkg/conversion"
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/jsonpath"
"k8s.io/kubernetes/pkg/util/jsonpath"
...
@@ -500,7 +501,7 @@ func printPodTemplate(pod *api.PodTemplate, w io.Writer, withNamespace bool, wid
...
@@ -500,7 +501,7 @@ func printPodTemplate(pod *api.PodTemplate, w io.Writer, withNamespace bool, wid
name
,
name
,
firstContainer
.
Name
,
firstContainer
.
Name
,
firstContainer
.
Image
,
firstContainer
.
Image
,
f
ormatLabels
(
pod
.
Template
.
Labels
),
labels
.
F
ormatLabels
(
pod
.
Template
.
Labels
),
);
err
!=
nil
{
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -553,7 +554,7 @@ func printReplicationController(controller *api.ReplicationController, w io.Writ
...
@@ -553,7 +554,7 @@ func printReplicationController(controller *api.ReplicationController, w io.Writ
name
,
name
,
firstContainer
.
Name
,
firstContainer
.
Name
,
firstContainer
.
Image
,
firstContainer
.
Image
,
f
ormatLabels
(
controller
.
Spec
.
Selector
),
labels
.
F
ormatLabels
(
controller
.
Spec
.
Selector
),
controller
.
Spec
.
Replicas
,
controller
.
Spec
.
Replicas
,
translateTimestamp
(
controller
.
CreationTimestamp
),
translateTimestamp
(
controller
.
CreationTimestamp
),
);
err
!=
nil
{
);
err
!=
nil
{
...
@@ -643,7 +644,7 @@ func printService(svc *api.Service, w io.Writer, withNamespace bool, wide bool,
...
@@ -643,7 +644,7 @@ func printService(svc *api.Service, w io.Writer, withNamespace bool, wide bool,
internalIP
,
internalIP
,
externalIP
,
externalIP
,
makePortString
(
svc
.
Spec
.
Ports
),
makePortString
(
svc
.
Spec
.
Ports
),
f
ormatLabels
(
svc
.
Spec
.
Selector
),
labels
.
F
ormatLabels
(
svc
.
Spec
.
Selector
),
translateTimestamp
(
svc
.
CreationTimestamp
),
translateTimestamp
(
svc
.
CreationTimestamp
),
);
err
!=
nil
{
);
err
!=
nil
{
return
err
return
err
...
@@ -693,7 +694,7 @@ func printNamespace(item *api.Namespace, w io.Writer, withNamespace bool, wide b
...
@@ -693,7 +694,7 @@ func printNamespace(item *api.Namespace, w io.Writer, withNamespace bool, wide b
return
fmt
.
Errorf
(
"namespace is not namespaced"
)
return
fmt
.
Errorf
(
"namespace is not namespaced"
)
}
}
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s"
,
item
.
Name
,
f
ormatLabels
(
item
.
Labels
),
item
.
Status
.
Phase
,
translateTimestamp
(
item
.
CreationTimestamp
));
err
!=
nil
{
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s"
,
item
.
Name
,
labels
.
F
ormatLabels
(
item
.
Labels
),
item
.
Status
.
Phase
,
translateTimestamp
(
item
.
CreationTimestamp
));
err
!=
nil
{
return
err
return
err
}
}
_
,
err
:=
fmt
.
Fprint
(
w
,
appendLabels
(
item
.
Labels
,
columnLabels
))
_
,
err
:=
fmt
.
Fprint
(
w
,
appendLabels
(
item
.
Labels
,
columnLabels
))
...
@@ -788,7 +789,7 @@ func printNode(node *api.Node, w io.Writer, withNamespace bool, wide bool, showA
...
@@ -788,7 +789,7 @@ func printNode(node *api.Node, w io.Writer, withNamespace bool, wide bool, showA
status
=
append
(
status
,
"SchedulingDisabled"
)
status
=
append
(
status
,
"SchedulingDisabled"
)
}
}
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s"
,
node
.
Name
,
f
ormatLabels
(
node
.
Labels
),
strings
.
Join
(
status
,
","
),
translateTimestamp
(
node
.
CreationTimestamp
));
err
!=
nil
{
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s"
,
node
.
Name
,
labels
.
F
ormatLabels
(
node
.
Labels
),
strings
.
Join
(
status
,
","
),
translateTimestamp
(
node
.
CreationTimestamp
));
err
!=
nil
{
return
err
return
err
}
}
_
,
err
:=
fmt
.
Fprint
(
w
,
appendLabels
(
node
.
Labels
,
columnLabels
))
_
,
err
:=
fmt
.
Fprint
(
w
,
appendLabels
(
node
.
Labels
,
columnLabels
))
...
@@ -824,7 +825,7 @@ func printPersistentVolume(pv *api.PersistentVolume, w io.Writer, withNamespace
...
@@ -824,7 +825,7 @@ func printPersistentVolume(pv *api.PersistentVolume, w io.Writer, withNamespace
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s"
,
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s"
,
name
,
name
,
f
ormatLabels
(
pv
.
Labels
),
labels
.
F
ormatLabels
(
pv
.
Labels
),
aSize
,
modesStr
,
aSize
,
modesStr
,
pv
.
Status
.
Phase
,
pv
.
Status
.
Phase
,
claimRefUID
,
claimRefUID
,
...
@@ -856,7 +857,7 @@ func printPersistentVolumeClaim(pvc *api.PersistentVolumeClaim, w io.Writer, wit
...
@@ -856,7 +857,7 @@ func printPersistentVolumeClaim(pvc *api.PersistentVolumeClaim, w io.Writer, wit
}
}
}
}
labels
:=
f
ormatLabels
(
pvc
.
Labels
)
labels
:=
labels
.
F
ormatLabels
(
pvc
.
Labels
)
phase
:=
pvc
.
Status
.
Phase
phase
:=
pvc
.
Status
.
Phase
storage
:=
pvc
.
Spec
.
Resources
.
Requests
[
api
.
ResourceStorage
]
storage
:=
pvc
.
Spec
.
Resources
.
Requests
[
api
.
ResourceStorage
]
capacity
:=
""
capacity
:=
""
...
...
pkg/labels/labels.go
View file @
36987e9d
...
@@ -60,3 +60,12 @@ func (ls Set) Get(label string) string {
...
@@ -60,3 +60,12 @@ func (ls Set) Get(label string) string {
func
(
ls
Set
)
AsSelector
()
Selector
{
func
(
ls
Set
)
AsSelector
()
Selector
{
return
SelectorFromSet
(
ls
)
return
SelectorFromSet
(
ls
)
}
}
// FormatLables convert label map into plain string
func
FormatLabels
(
labelMap
map
[
string
]
string
)
string
{
l
:=
Set
(
labelMap
)
.
String
()
if
l
==
""
{
l
=
"<none>"
}
return
l
}
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