mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #81592 from serathius/stable-metric-analysis-stdin
Pass list of files through stdin to avoid hitting ARG_MAX on some env…
This commit is contained in:
commit
37edb6984b
@ -44,7 +44,7 @@ genrule(
|
||||
"//:all-srcs",
|
||||
],
|
||||
outs = ["stable-metrics-list.yaml"],
|
||||
cmd = "./$(locations :instrumentation) $(locations //:all-srcs) > $@",
|
||||
cmd = "for loc in $(locations //:all-srcs); do echo $$loc; done | ./$(locations :instrumentation) - > $@",
|
||||
message = "Listing all stable metrics.",
|
||||
tools = [":instrumentation"],
|
||||
)
|
||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
@ -42,18 +43,34 @@ const (
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if len(flag.Args()) < 1 {
|
||||
fmt.Fprintf(os.Stderr, "USAGE: %s <DIR or FILE> [...]\n", os.Args[0])
|
||||
fmt.Fprintf(os.Stderr, "USAGE: %s <DIR or FILE or '-'> [...]\n", os.Args[0])
|
||||
os.Exit(64)
|
||||
}
|
||||
|
||||
stableMetrics := []metric{}
|
||||
errors := []error{}
|
||||
|
||||
addStdin := false
|
||||
for _, arg := range flag.Args() {
|
||||
if arg == "-" {
|
||||
addStdin = true
|
||||
continue
|
||||
}
|
||||
ms, es := searchPathForStableMetrics(arg)
|
||||
stableMetrics = append(stableMetrics, ms...)
|
||||
errors = append(errors, es...)
|
||||
}
|
||||
if addStdin {
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
scanner.Split(bufio.ScanLines)
|
||||
for scanner.Scan() {
|
||||
arg := scanner.Text()
|
||||
ms, es := searchPathForStableMetrics(arg)
|
||||
stableMetrics = append(stableMetrics, ms...)
|
||||
errors = append(errors, es...)
|
||||
}
|
||||
}
|
||||
|
||||
for _, err := range errors {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user