mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-21 19:07:00 +00:00
Also read up to 256MB from stdin
This commit is contained in:
parent
4a8aace275
commit
b5c823d6b5
3 changed files with 10 additions and 4 deletions
|
|
@ -294,3 +294,9 @@ resetCacheFolder() {
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ "$output" = 'Summary: 100000 resources found in 1 file - Valid: 100000, Invalid: 0, Errors: 0, Skipped: 0' ]
|
[ "$output" = 'Summary: 100000 resources found in 1 file - Valid: 100000, Invalid: 0, Errors: 0, Skipped: 0' ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "Should support very long streams from stdin" {
|
||||||
|
run bash -c "cat fixtures/valid_large.yaml | bin/kubeconform -summary"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$output" = 'Summary: 100000 resources found parsing stdin - Valid: 100000, Invalid: 0, Errors: 0, Skipped: 0' ]
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ func findResourcesInReader(p string, f io.Reader, resources chan<- Resource, err
|
||||||
scanner := bufio.NewScanner(f)
|
scanner := bufio.NewScanner(f)
|
||||||
// We start with a buf that is 4MB, scanner will resize it up to 256MB if needed
|
// We start with a buf that is 4MB, scanner will resize it up to 256MB if needed
|
||||||
// https://github.com/golang/go/blob/aeea5bacbf79fb945edbeac6cd7630dd70c4d9ce/src/bufio/scan.go#L191
|
// https://github.com/golang/go/blob/aeea5bacbf79fb945edbeac6cd7630dd70c4d9ce/src/bufio/scan.go#L191
|
||||||
scanner.Buffer(buf, 256*1024*1024*1024)
|
scanner.Buffer(buf, 256*1024*1024)
|
||||||
scanner.Split(SplitYAMLDocument)
|
scanner.Split(SplitYAMLDocument)
|
||||||
nRes := 0
|
nRes := 0
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,9 @@ func FromStream(ctx context.Context, path string, r io.Reader) (<-chan Resource,
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
scanner := bufio.NewScanner(r)
|
scanner := bufio.NewScanner(r)
|
||||||
const maxResourceSize = 4 * 1024 * 1024 // 4MB ought to be enough for everybody
|
const maxResourceSize = 4 * 1024 * 1024 // Start with 4MB
|
||||||
buf := make([]byte, maxResourceSize)
|
buf := make([]byte, maxResourceSize)
|
||||||
scanner.Buffer(buf, maxResourceSize)
|
scanner.Buffer(buf, 256*1024*1024) // Resize up to 256MB
|
||||||
scanner.Split(SplitYAMLDocument)
|
scanner.Split(SplitYAMLDocument)
|
||||||
|
|
||||||
SCAN:
|
SCAN:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue