mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-10-29 12:49:55 +00:00
Allows to read from multiple logs simultaneously
Which makes possible to combile the `-f` and `-l` flags in kubectl logs
This commit is contained in:
@@ -32,7 +32,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/kubectl/util/podutils"
|
||||
)
|
||||
|
||||
func logsForObject(restClientGetter genericclioptions.RESTClientGetter, object, options runtime.Object, timeout time.Duration, allContainers bool) ([]*rest.Request, error) {
|
||||
func logsForObject(restClientGetter genericclioptions.RESTClientGetter, object, options runtime.Object, timeout time.Duration, allContainers bool) ([]rest.ResponseWrapper, error) {
|
||||
clientConfig, err := restClientGetter.ToRESTConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -47,7 +47,7 @@ func logsForObject(restClientGetter genericclioptions.RESTClientGetter, object,
|
||||
|
||||
// TODO: remove internal clientset once all callers use external versions
|
||||
// this is split for easy test-ability
|
||||
func logsForObjectWithClient(clientset corev1client.CoreV1Interface, object, options runtime.Object, timeout time.Duration, allContainers bool) ([]*rest.Request, error) {
|
||||
func logsForObjectWithClient(clientset corev1client.CoreV1Interface, object, options runtime.Object, timeout time.Duration, allContainers bool) ([]rest.ResponseWrapper, error) {
|
||||
opts, ok := options.(*corev1.PodLogOptions)
|
||||
if !ok {
|
||||
return nil, errors.New("provided options object is not a PodLogOptions")
|
||||
@@ -55,7 +55,7 @@ func logsForObjectWithClient(clientset corev1client.CoreV1Interface, object, opt
|
||||
|
||||
switch t := object.(type) {
|
||||
case *corev1.PodList:
|
||||
ret := []*rest.Request{}
|
||||
ret := []rest.ResponseWrapper{}
|
||||
for i := range t.Items {
|
||||
currRet, err := logsForObjectWithClient(clientset, &t.Items[i], options, timeout, allContainers)
|
||||
if err != nil {
|
||||
@@ -68,10 +68,10 @@ func logsForObjectWithClient(clientset corev1client.CoreV1Interface, object, opt
|
||||
case *corev1.Pod:
|
||||
// if allContainers is true, then we're going to locate all containers and then iterate through them. At that point, "allContainers" is false
|
||||
if !allContainers {
|
||||
return []*rest.Request{clientset.Pods(t.Namespace).GetLogs(t.Name, opts)}, nil
|
||||
return []rest.ResponseWrapper{clientset.Pods(t.Namespace).GetLogs(t.Name, opts)}, nil
|
||||
}
|
||||
|
||||
ret := []*rest.Request{}
|
||||
ret := []rest.ResponseWrapper{}
|
||||
for _, c := range t.Spec.InitContainers {
|
||||
currOpts := opts.DeepCopy()
|
||||
currOpts.Container = c.Name
|
||||
|
||||
Reference in New Issue
Block a user