mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Merge pull request #82010 from verb/range-kubectl
Update kubectl polymorphic logs helper for ephemeral containers
This commit is contained in:
commit
bdea3c0181
@ -89,6 +89,15 @@ func logsForObjectWithClient(clientset corev1client.CoreV1Interface, object, opt
|
|||||||
}
|
}
|
||||||
ret = append(ret, currRet...)
|
ret = append(ret, currRet...)
|
||||||
}
|
}
|
||||||
|
for _, c := range t.Spec.EphemeralContainers {
|
||||||
|
currOpts := opts.DeepCopy()
|
||||||
|
currOpts.Container = c.Name
|
||||||
|
currRet, err := logsForObjectWithClient(clientset, t, currOpts, timeout, false)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ret = append(ret, currRet...)
|
||||||
|
}
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,11 @@ func TestLogsForObject(t *testing.T) {
|
|||||||
{Name: "c1"},
|
{Name: "c1"},
|
||||||
{Name: "c2"},
|
{Name: "c2"},
|
||||||
},
|
},
|
||||||
|
EphemeralContainers: []corev1.EphemeralContainer{
|
||||||
|
{
|
||||||
|
EphemeralContainerCommon: corev1.EphemeralContainerCommon{Name: "e1"},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
opts: &corev1.PodLogOptions{},
|
opts: &corev1.PodLogOptions{},
|
||||||
@ -80,6 +85,7 @@ func TestLogsForObject(t *testing.T) {
|
|||||||
getLogsAction("test", &corev1.PodLogOptions{Container: "initc2"}),
|
getLogsAction("test", &corev1.PodLogOptions{Container: "initc2"}),
|
||||||
getLogsAction("test", &corev1.PodLogOptions{Container: "c1"}),
|
getLogsAction("test", &corev1.PodLogOptions{Container: "c1"}),
|
||||||
getLogsAction("test", &corev1.PodLogOptions{Container: "c2"}),
|
getLogsAction("test", &corev1.PodLogOptions{Container: "c2"}),
|
||||||
|
getLogsAction("test", &corev1.PodLogOptions{Container: "e1"}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -215,18 +221,22 @@ func TestLogsForObject(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range test.actions {
|
var i int
|
||||||
|
for i = range test.actions {
|
||||||
if len(fakeClientset.Actions()) < i {
|
if len(fakeClientset.Actions()) < i {
|
||||||
t.Errorf("%s: action %d does not exists in actual actions: %#v",
|
t.Errorf("%s: expected action %d does not exists in actual actions: %#v",
|
||||||
test.name, i, fakeClientset.Actions())
|
test.name, i, fakeClientset.Actions())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
got := fakeClientset.Actions()[i]
|
got := fakeClientset.Actions()[i]
|
||||||
want := test.actions[i]
|
want := test.actions[i]
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !reflect.DeepEqual(got, want) {
|
||||||
t.Errorf("%s: unexpected action: %s", test.name, diff.ObjectDiff(got, want))
|
t.Errorf("%s: unexpected diff for action: %s", test.name, diff.ObjectDiff(got, want))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for i++; i < len(fakeClientset.Actions()); i++ {
|
||||||
|
t.Errorf("%s: actual action %d does not exist in expected: %v", test.name, i, fakeClientset.Actions()[i])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user