File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -46,9 +46,33 @@ done < <(echo "${all_packages[@]}" | tr " " "\n")
46
46
47
47
ret=0
48
48
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
51
72
52
73
if [ $ret -eq 0 ]; then
53
74
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
54
78
fi
You can’t perform that action at this time.
0 commit comments