fix arguments too long error

This commit is contained in:
Han Kang 2021-02-08 11:44:47 -08:00
parent db107b190c
commit c3f550f3cb
3 changed files with 25 additions and 33 deletions

View File

@ -74,12 +74,16 @@ func main() {
if len(errors) != 0 {
os.Exit(1)
}
if len(stableMetrics) == 0 {
os.Exit(0)
}
sort.Sort(byFQName(stableMetrics))
data, err := yaml.Marshal(stableMetrics)
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
fmt.Print(string(data))
}

View File

@ -44,7 +44,7 @@ find_files_to_check() {
-o -wholename '*/third_party/*' \
-o -wholename '*/vendor/*' \
-o -wholename '*/hack/*' \
-o -wholename '**/*_test.go' \
-o -wholename '*_test.go' \
\) -prune \
\) \
\( -wholename '**/*.go' \
@ -57,43 +57,32 @@ reset=$(tput sgr0)
kube::validate::stablemetrics() {
stability_check_setup
static_checked_files=$(find_files_to_check | grep -E ".*.go" | grep -v ".*_test.go") || true
temp_file=$(mktemp)
gopathfiles=$(find_files_to_check | grep -E 'test/instrumentation/.*.go' | grep -v "test/instrumentation/main.*go" | cut -c 3-)
for i in "${static_checked_files[@]}"
do
# Deliberately allow word split here
# shellcheck disable=SC2086
stabilitycheck=$(go run "test/instrumentation/main.go" $gopathfiles -- $i 1>$temp_file)
if $stabilitycheck; then
echo -e "${green}Diffing test/instrumentation/testdata/stable-metrics-list.yaml\n${reset}"
if diff -u "$KUBE_ROOT/test/instrumentation/testdata/stable-metrics-list.yaml" "$temp_file"; then
echo -e "${green}\nPASS metrics stability verification ${reset}"
return 0
fi
doValidate=$(find_files_to_check | grep -E ".*.go" | grep -v ".*_test.go" | sort | xargs -L 200 go run "test/instrumentation/main.go" "test/instrumentation/decode_metric.go" "test/instrumentation/find_stable_metric.go" "test/instrumentation/error.go" "test/instrumentation/metric.go" -- 1>"${temp_file}")
if $doValidate; then
echo -e "${green}Diffing test/instrumentation/testdata/stable-metrics-list.yaml\n${reset}"
if diff -u "$KUBE_ROOT/test/instrumentation/testdata/stable-metrics-list.yaml" "$temp_file"; then
echo -e "${green}\nPASS metrics stability verification ${reset}"
return 0
fi
echo "${red}!!! Metrics Stability static analysis has failed!${reset}" >&2
echo "${red}!!! Please run ./hack/update-generated-stable-metrics.sh to update the golden list.${reset}" >&2
exit 1
done
fi
echo "${red}!!! Metrics Stability static analysis has failed!${reset}" >&2
echo "${red}!!! Please run ./hack/update-generated-stable-metrics.sh to update the golden list.${reset}" >&2
exit 1
}
kube::update::stablemetrics() {
stability_check_setup
static_checked_files=$(find_files_to_check | grep -E ".*.go" | grep -v ".*_test.go") || true
temp_file=$(mktemp)
gopathfiles=$(find_files_to_check | grep -E 'test/instrumentation/.*.go' | grep -v "test/instrumentation/main.*go" | cut -c 3-)
for i in "${static_checked_files[@]}"
do
# Deliberately allow word split here
# shellcheck disable=SC2086
stabilitycheck=$(go run "test/instrumentation/main.go" $gopathfiles -- $i 1>$temp_file)
if ! $stabilitycheck; then
echo "${red}!!! updating golden list of metrics has failed! ${reset}" >&2
exit 1
fi
mv -f "$temp_file" "${KUBE_ROOT}/test/instrumentation/testdata/stable-metrics-list.yaml"
echo "${green}Updated golden list of stable metrics.${reset}"
done
doCheckStability=$(find_files_to_check | grep -E ".*.go" | grep -v ".*_test.go" | sort | xargs -L 200 go run "test/instrumentation/main.go" "test/instrumentation/decode_metric.go" "test/instrumentation/find_stable_metric.go" "test/instrumentation/error.go" "test/instrumentation/metric.go" -- 1>"${temp_file}")
if ! $doCheckStability; then
echo "${red}!!! updating golden list of metrics has failed! ${reset}" >&2
exit 1
fi
mv -f "$temp_file" "${KUBE_ROOT}/test/instrumentation/testdata/stable-metrics-list.yaml"
echo "${green}Updated golden list of stable metrics.${reset}"
}

View File

@ -1 +0,0 @@
[]