mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
rename to sharedLimitWriter
This commit is contained in:
parent
a4230055f3
commit
0e178f9341
@ -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,
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user