Update the util/kubernetes client to retrieve logs

This commit is contained in:
Jake Sanders
2019-12-17 16:09:51 +00:00
parent 0415ead504
commit 53ca742c66
7 changed files with 85 additions and 9 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"crypto/tls"
"errors"
"io"
"io/ioutil"
"net/http"
"os"
@@ -116,6 +117,21 @@ func (c *client) Get(r *Resource, labels map[string]string) error {
Into(r.Value)
}
// Logs returns logs for a pod
func (c *client) Logs(podName string) (io.ReadCloser, error) {
req := api.NewRequest(c.opts).
Get().
Resource("pod").
SubResource("log").
Name(podName)
resp, err := req.Raw()
if err != nil {
return nil, err
}
return resp.Body, nil
}
// Update updates API object
func (c *client) Update(r *Resource) error {
req := api.NewRequest(c.opts).