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
1a1b940e
Commit
1a1b940e
authored
Aug 19, 2017
by
zhengjiajin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue(#50937)Fix kubectl get pvc lose volume name
parent
2ba796fe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
0 deletions
+101
-0
printers.go
pkg/printers/internalversion/printers.go
+1
-0
printers_test.go
pkg/printers/internalversion/printers_test.go
+100
-0
No files found.
pkg/printers/internalversion/printers.go
View file @
1a1b940e
...
@@ -277,6 +277,7 @@ func AddHandlers(h printers.PrintHandler) {
...
@@ -277,6 +277,7 @@ func AddHandlers(h printers.PrintHandler) {
persistentVolumeClaimColumnDefinitions
:=
[]
metav1alpha1
.
TableColumnDefinition
{
persistentVolumeClaimColumnDefinitions
:=
[]
metav1alpha1
.
TableColumnDefinition
{
{
Name
:
"Name"
,
Type
:
"string"
,
Format
:
"name"
,
Description
:
metav1
.
ObjectMeta
{}
.
SwaggerDoc
()[
"name"
]},
{
Name
:
"Name"
,
Type
:
"string"
,
Format
:
"name"
,
Description
:
metav1
.
ObjectMeta
{}
.
SwaggerDoc
()[
"name"
]},
{
Name
:
"Status"
,
Type
:
"string"
,
Description
:
apiv1
.
PersistentVolumeClaimStatus
{}
.
SwaggerDoc
()[
"phase"
]},
{
Name
:
"Status"
,
Type
:
"string"
,
Description
:
apiv1
.
PersistentVolumeClaimStatus
{}
.
SwaggerDoc
()[
"phase"
]},
{
Name
:
"Volume"
,
Type
:
"string"
,
Description
:
apiv1
.
PersistentVolumeSpec
{}
.
SwaggerDoc
()[
"volumeName"
]},
{
Name
:
"Capacity"
,
Type
:
"string"
,
Description
:
apiv1
.
PersistentVolumeClaimStatus
{}
.
SwaggerDoc
()[
"capacity"
]},
{
Name
:
"Capacity"
,
Type
:
"string"
,
Description
:
apiv1
.
PersistentVolumeClaimStatus
{}
.
SwaggerDoc
()[
"capacity"
]},
{
Name
:
"Access Modes"
,
Type
:
"string"
,
Description
:
apiv1
.
PersistentVolumeClaimStatus
{}
.
SwaggerDoc
()[
"accessModes"
]},
{
Name
:
"Access Modes"
,
Type
:
"string"
,
Description
:
apiv1
.
PersistentVolumeClaimStatus
{}
.
SwaggerDoc
()[
"accessModes"
]},
{
Name
:
"StorageClass"
,
Type
:
"string"
,
Description
:
"StorageClass of the pvc"
},
{
Name
:
"StorageClass"
,
Type
:
"string"
,
Description
:
"StorageClass of the pvc"
},
...
...
pkg/printers/internalversion/printers_test.go
View file @
1a1b940e
...
@@ -2882,3 +2882,103 @@ func TestPrintReplicaSet(t *testing.T) {
...
@@ -2882,3 +2882,103 @@ func TestPrintReplicaSet(t *testing.T) {
buf
.
Reset
()
buf
.
Reset
()
}
}
}
}
func
TestPrintPersistentVolumeClaim
(
t
*
testing
.
T
)
{
myScn
:=
"my-scn"
tests
:=
[]
struct
{
pvc
api
.
PersistentVolumeClaim
expect
string
}{
{
// Test name, num of containers, restarts, container ready status
api
.
PersistentVolumeClaim
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test1"
,
},
Spec
:
api
.
PersistentVolumeClaimSpec
{
VolumeName
:
"my-volume"
,
},
Status
:
api
.
PersistentVolumeClaimStatus
{
Phase
:
api
.
ClaimBound
,
AccessModes
:
[]
api
.
PersistentVolumeAccessMode
{
api
.
ReadOnlyMany
},
Capacity
:
map
[
api
.
ResourceName
]
resource
.
Quantity
{
api
.
ResourceStorage
:
resource
.
MustParse
(
"4Gi"
),
},
},
},
"test1
\t
Bound
\t
my-volume
\t
4Gi
\t
ROX
\t\t
<unknown>
\n
"
,
},
{
// Test name, num of containers, restarts, container ready status
api
.
PersistentVolumeClaim
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test2"
,
},
Spec
:
api
.
PersistentVolumeClaimSpec
{},
Status
:
api
.
PersistentVolumeClaimStatus
{
Phase
:
api
.
ClaimLost
,
AccessModes
:
[]
api
.
PersistentVolumeAccessMode
{
api
.
ReadOnlyMany
},
Capacity
:
map
[
api
.
ResourceName
]
resource
.
Quantity
{
api
.
ResourceStorage
:
resource
.
MustParse
(
"4Gi"
),
},
},
},
"test2
\t
Lost
\t\t\t\t\t
<unknown>
\n
"
,
},
{
// Test name, num of containers, restarts, container ready status
api
.
PersistentVolumeClaim
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test3"
,
},
Spec
:
api
.
PersistentVolumeClaimSpec
{
VolumeName
:
"my-volume"
,
},
Status
:
api
.
PersistentVolumeClaimStatus
{
Phase
:
api
.
ClaimPending
,
AccessModes
:
[]
api
.
PersistentVolumeAccessMode
{
api
.
ReadWriteMany
},
Capacity
:
map
[
api
.
ResourceName
]
resource
.
Quantity
{
api
.
ResourceStorage
:
resource
.
MustParse
(
"10Gi"
),
},
},
},
"test3
\t
Pending
\t
my-volume
\t
10Gi
\t
RWX
\t\t
<unknown>
\n
"
,
},
{
// Test name, num of containers, restarts, container ready status
api
.
PersistentVolumeClaim
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test4"
,
},
Spec
:
api
.
PersistentVolumeClaimSpec
{
VolumeName
:
"my-volume"
,
StorageClassName
:
&
myScn
,
},
Status
:
api
.
PersistentVolumeClaimStatus
{
Phase
:
api
.
ClaimPending
,
AccessModes
:
[]
api
.
PersistentVolumeAccessMode
{
api
.
ReadWriteOnce
},
Capacity
:
map
[
api
.
ResourceName
]
resource
.
Quantity
{
api
.
ResourceStorage
:
resource
.
MustParse
(
"10Gi"
),
},
},
},
"test4
\t
Pending
\t
my-volume
\t
10Gi
\t
RWO
\t
my-scn
\t
<unknown>
\n
"
,
},
}
buf
:=
bytes
.
NewBuffer
([]
byte
{})
for
_
,
test
:=
range
tests
{
table
,
err
:=
printers
.
NewTablePrinter
()
.
With
(
AddHandlers
)
.
PrintTable
(
&
test
.
pvc
,
printers
.
PrintOptions
{})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
printers
.
PrintTable
(
table
,
buf
,
printers
.
PrintOptions
{
NoHeaders
:
true
});
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
buf
.
String
()
!=
test
.
expect
{
fmt
.
Println
(
buf
.
String
())
fmt
.
Println
(
test
.
expect
)
t
.
Fatalf
(
"Expected: %s, but got: %s"
,
test
.
expect
,
buf
.
String
())
}
buf
.
Reset
()
}
}
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