Skip to content

Commit e42fe3d

Browse files
authored
Merge pull request #831 from googs1025/chore/conextual_ci
chore: renew verify conextual structured script
2 parents a26beb4 + bbd2ef2 commit e42fe3d

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

hack/verify-structured-logging.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,33 @@ done < <(echo "${all_packages[@]}" | tr " " "\n")
4646

4747
ret=0
4848
echo -e "\nRunning structured logging static check on all packages"
49-
GOOS=linux logcheck "${packages[@]}" || ret=$?
50-
GOOS=windows logcheck "${packages[@]}" || ret=$?
49+
50+
# Function to run logcheck and capture output
51+
run_logcheck() {
52+
local os="$1"
53+
shift
54+
local output
55+
output=$(GOOS="$os" logcheck "$@" 2>&1)
56+
# TODO: Add more checks as needed
57+
# Currently, we only check for unstructured logging
58+
# more detail: https://github.com/kubernetes-sigs/scheduler-plugins/pull/831#discussion_r1835553079
59+
errors=$(echo "$output" | grep 'unstructured logging function')
60+
if [[ $? -eq 0 ]]; then
61+
echo "Error: Unstructured logging detected. Please fix the issues."
62+
echo "$errors"
63+
return 1
64+
fi
65+
}
66+
67+
# Run logcheck for Linux
68+
echo "Running logcheck for Linux..."
69+
if ! run_logcheck linux "${packages[@]}"; then
70+
ret=1
71+
fi
5172

5273
if [ $ret -eq 0 ]; then
5374
echo "Structured logging static check passed on all packages :)"
75+
else
76+
echo "Structured logging static check failed. Please fix the issues."
77+
exit 1
5478
fi

0 commit comments

Comments
 (0)