mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #76463 from j-griffith/add_datasource_to_pvc_describe
Add DataSource to PVC describe
This commit is contained in:
commit
9dad928e6b
@ -1534,6 +1534,11 @@ func describePersistentVolumeClaim(pvc *corev1.PersistentVolumeClaim, events *co
|
||||
if pvc.Spec.VolumeMode != nil {
|
||||
w.Write(LEVEL_0, "VolumeMode:\t%v\n", *pvc.Spec.VolumeMode)
|
||||
}
|
||||
if pvc.Spec.DataSource != nil {
|
||||
w.Write(LEVEL_0, "DataSource:\n")
|
||||
w.Write(LEVEL_1, "Name:\t%v\n", pvc.Spec.DataSource.Name)
|
||||
w.Write(LEVEL_1, "Kind:\t%v\n", pvc.Spec.DataSource.Kind)
|
||||
}
|
||||
printPodsMultiline(w, "Mounted By", mountPods)
|
||||
|
||||
if len(pvc.Status.Conditions) > 0 {
|
||||
|
@ -1306,6 +1306,7 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
|
||||
goldClassName := "gold"
|
||||
now := time.Now()
|
||||
deletionTimestamp := metav1.Time{Time: time.Now().UTC().AddDate(-10, 0, 0)}
|
||||
snapshotAPIGroup := "snapshot.storage.k8s.io"
|
||||
testCases := []struct {
|
||||
name string
|
||||
pvc *corev1.PersistentVolumeClaim
|
||||
@ -1469,6 +1470,45 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
|
||||
},
|
||||
expectedElements: []string{"Terminating (lasts 10y)"},
|
||||
},
|
||||
{
|
||||
name: "pvc-datasource",
|
||||
pvc: &corev1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "foo",
|
||||
Name: "bar",
|
||||
},
|
||||
Spec: corev1.PersistentVolumeClaimSpec{
|
||||
VolumeName: "volume10",
|
||||
StorageClassName: &goldClassName,
|
||||
DataSource: &corev1.TypedLocalObjectReference{
|
||||
Name: "srcpvc",
|
||||
Kind: "PersistentVolumeClaim",
|
||||
},
|
||||
},
|
||||
Status: corev1.PersistentVolumeClaimStatus{},
|
||||
},
|
||||
expectedElements: []string{"\nDataSource:\n Name: srcpvc\n Kind: PersistentVolumeClaim"},
|
||||
},
|
||||
{
|
||||
name: "snapshot-datasource",
|
||||
pvc: &corev1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "foo",
|
||||
Name: "bar",
|
||||
},
|
||||
Spec: corev1.PersistentVolumeClaimSpec{
|
||||
VolumeName: "volume10",
|
||||
StorageClassName: &goldClassName,
|
||||
DataSource: &corev1.TypedLocalObjectReference{
|
||||
Name: "src-snapshot",
|
||||
Kind: "VolumeSnapshot",
|
||||
APIGroup: &snapshotAPIGroup,
|
||||
},
|
||||
},
|
||||
Status: corev1.PersistentVolumeClaimStatus{},
|
||||
},
|
||||
expectedElements: []string{"DataSource:\n Name: src-snapshot\n Kind: VolumeSnapshot\n"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
@ -3090,6 +3130,12 @@ func TestDescribeStatefulSet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// boolPtr returns a pointer to a bool
|
||||
func boolPtr(b bool) *bool {
|
||||
o := b
|
||||
return &o
|
||||
}
|
||||
|
||||
func TestControllerRef(t *testing.T) {
|
||||
var replicas int32 = 1
|
||||
f := fake.NewSimpleClientset(
|
||||
|
Loading…
Reference in New Issue
Block a user