|
|
@ -31,7 +31,7 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
"k8s.io/apimachinery/pkg/api/meta"
|
|
|
|
"k8s.io/apimachinery/pkg/api/meta"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/evanphx/json-patch"
|
|
|
|
jsonpatch "github.com/evanphx/json-patch"
|
|
|
|
appsv1 "k8s.io/api/apps/v1"
|
|
|
|
appsv1 "k8s.io/api/apps/v1"
|
|
|
|
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
|
|
|
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
|
|
|
appsv1beta2 "k8s.io/api/apps/v1beta2"
|
|
|
|
appsv1beta2 "k8s.io/api/apps/v1beta2"
|
|
|
@ -948,24 +948,17 @@ func (c *Client) watchPodUntilComplete(timeout time.Duration, info *resource.Inf
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GetPodLogs takes pod name and namespace and returns the current logs (streaming is NOT enabled).
|
|
|
|
// GetPodLogs takes pod name and namespace and returns the current logs (streaming is NOT enabled).
|
|
|
|
func (c *Client) GetPodLogs(name, ns string) (string, error) {
|
|
|
|
func (c *Client) GetPodLogs(name, ns string) (io.ReadCloser, error) {
|
|
|
|
client, err := c.KubernetesClientSet()
|
|
|
|
client, err := c.KubernetesClientSet()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
req := client.CoreV1().Pods(ns).GetLogs(name, &v1.PodLogOptions{})
|
|
|
|
req := client.CoreV1().Pods(ns).GetLogs(name, &v1.PodLogOptions{})
|
|
|
|
podLogs, err := req.Stream()
|
|
|
|
logReader, err := req.Stream()
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return "", fmt.Errorf("error in opening log stream, got: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
defer podLogs.Close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
|
|
|
|
_, err = io.Copy(buf, podLogs)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return "", fmt.Errorf("error in copy information from log stream to buf, got: %s", err)
|
|
|
|
return nil, fmt.Errorf("error in opening log stream, got: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return buf.String(), nil
|
|
|
|
return logReader, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func isPodComplete(event watch.Event) (bool, error) {
|
|
|
|
func isPodComplete(event watch.Event) (bool, error) {
|
|
|
|