@@ -115,19 +115,25 @@ func GetPods(t Test, namespace string, options metav1.ListOptions) []corev1.Pod
115115 return pods .Items
116116}
117117
118- func GetPodLogs (t Test , pod * corev1. Pod , options corev1.PodLogOptions ) [] byte {
119- t . T (). Helper ()
120- stream , err := t .Client ().Core ().CoreV1 ().Pods (pod . GetNamespace ()) .GetLogs (pod . GetName () , & options ).Stream (t .Ctx ())
121- t .Expect (err ).NotTo (gomega .HaveOccurred ())
118+ func PodLog (t Test , namespace , name string , options corev1.PodLogOptions ) func ( g gomega. Gomega ) string {
119+ return func ( g gomega. Gomega ) string {
120+ stream , err := t .Client ().Core ().CoreV1 ().Pods (namespace ) .GetLogs (name , & options ).Stream (t .Ctx ())
121+ g .Expect (err ).NotTo (gomega .HaveOccurred ())
122122
123- defer func () {
124- t .Expect (stream .Close ()).To (gomega .Succeed ())
125- }()
123+ defer func () {
124+ g .Expect (stream .Close ()).To (gomega .Succeed ())
125+ }()
126126
127- bytes , err := io .ReadAll (stream )
128- t .Expect (err ).NotTo (gomega .HaveOccurred ())
127+ bytes , err := io .ReadAll (stream )
128+ g .Expect (err ).NotTo (gomega .HaveOccurred ())
129129
130- return bytes
130+ return string (bytes )
131+ }
132+ }
133+
134+ func GetPodLog (t Test , namespace , name string , options corev1.PodLogOptions ) string {
135+ t .T ().Helper ()
136+ return PodLog (t , namespace , name , options )(t )
131137}
132138
133139func storeAllPodLogs (t Test , namespace * corev1.Namespace ) {
0 commit comments