@@ -41,15 +41,6 @@ import (
41
41
clientset "k8s.io/client-go/kubernetes"
42
42
)
43
43
44
- // LogsForPod starts reading the logs for a certain pod. If the pod has more than one
45
- // container, opts.Container must be set. Reading stops when the context is done.
46
- // The stream includes formatted error messages and ends with
47
- // rpc error: code = Unknown desc = Error: No such container: 41a...
48
- // when the pod gets deleted while streaming.
49
- func LogsForPod (ctx context.Context , cs clientset.Interface , ns , pod string , opts * v1.PodLogOptions ) (io.ReadCloser , error ) {
50
- return cs .CoreV1 ().Pods (ns ).GetLogs (pod , opts ).Stream (ctx )
51
- }
52
-
53
44
// LogOutput determines where output from CopyAllLogs goes.
54
45
type LogOutput struct {
55
46
// If not nil, errors will be logged here.
@@ -110,7 +101,7 @@ func CopyAllLogs(ctx context.Context, cs clientset.Interface, ns string, to LogO
110
101
pod .Status .ContainerStatuses [i ].State .Terminated == nil ) {
111
102
continue
112
103
}
113
- readCloser , err := LogsForPod (ctx , cs , ns , pod .ObjectMeta .Name ,
104
+ readCloser , err := logsForPod (ctx , cs , ns , pod .ObjectMeta .Name ,
114
105
& v1.PodLogOptions {
115
106
Container : c .Name ,
116
107
Follow : true ,
@@ -210,6 +201,15 @@ func CopyAllLogs(ctx context.Context, cs clientset.Interface, ns string, to LogO
210
201
return nil
211
202
}
212
203
204
+ // logsForPod starts reading the logs for a certain pod. If the pod has more than one
205
+ // container, opts.Container must be set. Reading stops when the context is done.
206
+ // The stream includes formatted error messages and ends with
207
+ // rpc error: code = Unknown desc = Error: No such container: 41a...
208
+ // when the pod gets deleted while streaming.
209
+ func logsForPod (ctx context.Context , cs clientset.Interface , ns , pod string , opts * v1.PodLogOptions ) (io.ReadCloser , error ) {
210
+ return cs .CoreV1 ().Pods (ns ).GetLogs (pod , opts ).Stream (ctx )
211
+ }
212
+
213
213
// WatchPods prints pod status events for a certain namespace or all namespaces
214
214
// when namespace name is empty.
215
215
func WatchPods (ctx context.Context , cs clientset.Interface , ns string , to io.Writer ) error {
0 commit comments