func Logs(pod *corev1.Pod) (string, error) {
	var (
		execOut bytes.Buffer
		execErr bytes.Buffer
	)
	if len(pod.Spec.Containers) != 1 {
		return "", fmt.Errorf("could not determine which container to use")
	}
	cmd := exec.Command("/bin/bash", "-c", fmt.Sprintf("%v logs --namespace %s %s", KubectlPath, pod.Namespace, pod.Name))
	cmd.Stdout = &execOut
	cmd.Stderr = &execErr
	err := cmd.Run()
	if err != nil {
		return "", fmt.Errorf("could not execute '%s %s': %v", cmd.Path, cmd.Args, err)
	}
	if execErr.Len() > 0 {
		return "", fmt.Errorf("stderr: %v", execErr.String())
	}
	return execOut.String(), nil
}
Logs returns the log entries of a given Pod.
package framework
import (
	"bytes"
	"context"
	"fmt"
	"os/exec"
	"strings"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/apimachinery/pkg/util/wait"
	"sigs.k8s.io/controller-runtime/pkg/client"
)
func secretManagerLogs(c client.Client, namespace string) (string, error) {
	pod, err := WaitForSMPod(namespace, c)
	if err != nil {
		return "", err
	}
	if isRunning, err := podRunningReady(pod); err == nil && isRunning {
		return Logs(pod)
	}
	return "", fmt.Errorf("no secret-manager pod is running (logs)")
}
func WaitForSMPod(ns string, c client.Client) (*corev1.Pod, error) {
	var pod *corev1.Pod
	var l corev1.PodList
	err := wait.Poll(Poll, DefaultTimeout, func() (bool, error) {
		ls, _ := labels.Parse("app=secret-manager")
		err := c.List(context.Background(), &l, &client.ListOptions{
			LabelSelector: ls,
		})
		if err != nil {
			return false, nil
		}
		for i := range l.Items {
			if strings.HasPrefix(l.Items[i].GetName(), "secret-manager") {
				isRunning, err := podRunningReady(&l.Items[i])
				if err != nil {
					continue
				}
				if isRunning {
					pod = &l.Items[i]
					return true, nil
				}
			}
		}
		return false, nil
	})
	if err != nil {
		if err == wait.ErrWaitTimeout {
			return nil, fmt.Errorf("timeout waiting at least one secret-manager pod running in namespace %v", ns)
		}
		return nil, err
	}
	return pod, nil
}