mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +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",
|
"//:all-srcs",
|
||||||
],
|
],
|
||||||
outs = ["stable-metrics-list.yaml"],
|
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.",
|
message = "Listing all stable metrics.",
|
||||||
tools = [":instrumentation"],
|
tools = [":instrumentation"],
|
||||||
)
|
)
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/ast"
|
"go/ast"
|
||||||
@ -42,18 +43,34 @@ const (
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if len(flag.Args()) < 1 {
|
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)
|
os.Exit(64)
|
||||||
}
|
}
|
||||||
|
|
||||||
stableMetrics := []metric{}
|
stableMetrics := []metric{}
|
||||||
errors := []error{}
|
errors := []error{}
|
||||||
|
|
||||||
|
addStdin := false
|
||||||
for _, arg := range flag.Args() {
|
for _, arg := range flag.Args() {
|
||||||
|
if arg == "-" {
|
||||||
|
addStdin = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
ms, es := searchPathForStableMetrics(arg)
|
ms, es := searchPathForStableMetrics(arg)
|
||||||
stableMetrics = append(stableMetrics, ms...)
|
stableMetrics = append(stableMetrics, ms...)
|
||||||
errors = append(errors, es...)
|
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 {
|
for _, err := range errors {
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", err)
|
fmt.Fprintf(os.Stderr, "%s\n", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user