cleanup req.Context() and ResponseWrapper
Kubernetes-commit: 968adfa99362f733ef82f4aabb34a59dbbd6e56a
This commit is contained in:
parent
5252eb1dd9
commit
4524edecce
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package clusterinfo
|
package clusterinfo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -263,7 +264,7 @@ func (o *ClusterInfoDumpOptions) Run() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, request := range requests {
|
for _, request := range requests {
|
||||||
data, err := request.DoRaw()
|
data, err := request.DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Print error and return.
|
// Print error and return.
|
||||||
writer.Write([]byte(fmt.Sprintf("Request log error: %s\n", err.Error())))
|
writer.Write([]byte(fmt.Sprintf("Request log error: %s\n", err.Error())))
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package logs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"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
|
// 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.
|
// not treat an io.EOF as an error to be reported.
|
||||||
func DefaultConsumeRequest(request rest.ResponseWrapper, out io.Writer) error {
|
func DefaultConsumeRequest(request rest.ResponseWrapper, out io.Writer) error {
|
||||||
readCloser, err := request.Stream()
|
readCloser, err := request.Stream(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package logs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
@ -667,12 +668,12 @@ type responseWrapperMock struct {
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *responseWrapperMock) DoRaw() ([]byte, error) {
|
func (r *responseWrapperMock) DoRaw(context.Context) ([]byte, error) {
|
||||||
data, _ := ioutil.ReadAll(r.data)
|
data, _ := ioutil.ReadAll(r.data)
|
||||||
return data, r.err
|
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
|
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 {
|
func (l *logTestMock) mockConsumeRequest(request restclient.ResponseWrapper, out io.Writer) error {
|
||||||
readCloser, err := request.Stream()
|
readCloser, err := request.Stream(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package metricsutil
|
package metricsutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"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) {
|
func GetHeapsterMetrics(cli *HeapsterMetricsClient, path string, params map[string]string) ([]byte, error) {
|
||||||
return cli.SVCClient.Services(cli.HeapsterNamespace).
|
return cli.SVCClient.Services(cli.HeapsterNamespace).
|
||||||
ProxyGet(cli.HeapsterScheme, cli.HeapsterService, cli.HeapsterPort, path, params).
|
ProxyGet(cli.HeapsterScheme, cli.HeapsterService, cli.HeapsterPort, path, params).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue