cleanup req.Context() and ResponseWrapper

Kubernetes-commit: 968adfa99362f733ef82f4aabb34a59dbbd6e56a
This commit is contained in:
Mike Danese 2020-01-27 18:52:27 -08:00 committed by Kubernetes Publisher
parent 5252eb1dd9
commit 4524edecce
4 changed files with 10 additions and 6 deletions

View File

@ -17,6 +17,7 @@ limitations under the License.
package clusterinfo
import (
"context"
"fmt"
"io"
"os"
@ -263,7 +264,7 @@ func (o *ClusterInfoDumpOptions) Run() error {
}
for _, request := range requests {
data, err := request.DoRaw()
data, err := request.DoRaw(context.TODO())
if err != nil {
// Print error and return.
writer.Write([]byte(fmt.Sprintf("Request log error: %s\n", err.Error())))

View File

@ -18,6 +18,7 @@ package logs
import (
"bufio"
"context"
"errors"
"fmt"
"io"
@ -404,7 +405,7 @@ func (o LogsOptions) addPrefixIfNeeded(ref corev1.ObjectReference, writer io.Wri
// Because the function is defined to read from request until io.EOF, it does
// not treat an io.EOF as an error to be reported.
func DefaultConsumeRequest(request rest.ResponseWrapper, out io.Writer) error {
readCloser, err := request.Stream()
readCloser, err := request.Stream(context.TODO())
if err != nil {
return err
}

View File

@ -18,6 +18,7 @@ package logs
import (
"bytes"
"context"
"errors"
"fmt"
"io"
@ -667,12 +668,12 @@ type responseWrapperMock struct {
err error
}
func (r *responseWrapperMock) DoRaw() ([]byte, error) {
func (r *responseWrapperMock) DoRaw(context.Context) ([]byte, error) {
data, _ := ioutil.ReadAll(r.data)
return data, r.err
}
func (r *responseWrapperMock) Stream() (io.ReadCloser, error) {
func (r *responseWrapperMock) Stream(context.Context) (io.ReadCloser, error) {
return ioutil.NopCloser(r.data), r.err
}
@ -687,7 +688,7 @@ type logTestMock struct {
}
func (l *logTestMock) mockConsumeRequest(request restclient.ResponseWrapper, out io.Writer) error {
readCloser, err := request.Stream()
readCloser, err := request.Stream(context.Background())
if err != nil {
return err
}

View File

@ -17,6 +17,7 @@ limitations under the License.
package metricsutil
import (
"context"
"encoding/json"
"errors"
"fmt"
@ -166,5 +167,5 @@ func (cli *HeapsterMetricsClient) GetPodMetrics(namespace string, podName string
func GetHeapsterMetrics(cli *HeapsterMetricsClient, path string, params map[string]string) ([]byte, error) {
return cli.SVCClient.Services(cli.HeapsterNamespace).
ProxyGet(cli.HeapsterScheme, cli.HeapsterService, cli.HeapsterPort, path, params).
DoRaw()
DoRaw(context.TODO())
}