rename to sharedLimitWriter

This commit is contained in:
James DeFelice 2020-02-14 13:48:41 -06:00 committed by James DeFelice
parent a4230055f3
commit 0e178f9341
3 changed files with 6 additions and 6 deletions

View File

@ -81,8 +81,8 @@ func (d *dockerService) GetContainerLogs(_ context.Context, pod *v1.Pod, contain
if logOptions.LimitBytes != nil {
// stdout and stderr share the total write limit
max := *logOptions.LimitBytes
stderr = limitedWriter(stderr, &max)
stdout = limitedWriter(stdout, &max)
stderr = sharedLimitWriter(stderr, &max)
stdout = sharedLimitWriter(stdout, &max)
}
sopts := libdocker.StreamOptions{
OutputStream: stdout,

View File

@ -426,7 +426,7 @@ func (w sharedWriteLimiter) Write(p []byte) (int, error) {
return n, err
}
func limitedWriter(w io.Writer, limit *int64) io.Writer {
func sharedLimitWriter(w io.Writer, limit *int64) io.Writer {
if w == nil {
return nil
}

View File

@ -389,7 +389,7 @@ func TestLimitedWriter(t *testing.T) {
} {
t.Run(name, func(t *testing.T) {
limit := tc.limit
w := limitedWriter(&tc.w, &limit)
w := sharedLimitWriter(&tc.w, &limit)
n, err := w.Write([]byte(tc.toWrite))
if int64(n) > max(0, tc.limit) {
t.Fatalf("bytes written (%d) exceeds limit (%d)", n, tc.limit)
@ -421,8 +421,8 @@ func TestLimitedWriter(t *testing.T) {
var (
b1, b2 bytes.Buffer
limit = int64(10)
w1 = limitedWriter(&b1, &limit)
w2 = limitedWriter(&b2, &limit)
w1 = sharedLimitWriter(&b1, &limit)
w2 = sharedLimitWriter(&b2, &limit)
ch = make(chan struct{})
wg sync.WaitGroup
)