Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go linter doesn't run against gwctl code #2918

Closed
dprotaso opened this issue Apr 1, 2024 · 2 comments · Fixed by #2989
Closed

go linter doesn't run against gwctl code #2918

dprotaso opened this issue Apr 1, 2024 · 2 comments · Fixed by #2989
Assignees

Comments

@dprotaso
Copy link
Contributor

dprotaso commented Apr 1, 2024

Seems it's a limitation of the linter - golangci/golangci-lint#828

Here's a patch to gateway APIs script that will do the linting in two phases. I don't want to PR this because there a dozen issues that would need to be addressed when adding this change

diff --git a/hack/verify-golint.sh b/hack/verify-golint.sh
index f14c7933..6fadd3b4 100755
--- a/hack/verify-golint.sh
+++ b/hack/verify-golint.sh
@@ -26,6 +26,21 @@ cd "${KUBE_ROOT}"
 # See configuration file in ${KUBE_ROOT}/.golangci.yml.
 mkdir -p cache
 
-docker run --rm -v $(pwd)/cache:/cache -v $(pwd):/app --security-opt="label=disable" -e GOLANGCI_LINT_CACHE=/cache -e GOFLAGS="-buildvcs=false"  -w /app "golangci/golangci-lint:$VERSION" golangci-lint run
+failed=0
+for module in $(find . -name "go.mod" | xargs -n1 dirname); do
+  echo "Linting ${module}"
+
+  docker run --rm \
+    -v $(pwd)/cache:/cache \
+    -v $(pwd):/app \
+    -w "/app/${module}" \
+    --security-opt="label=disable" \
+    -e GOLANGCI_LINT_CACHE=/cache \
+    -e GOFLAGS="-buildvcs=false" \
+    "golangci/golangci-lint:$VERSION" \
+    golangci-lint run || failed=1
+done
+
+[[ $failed -eq 1 ]] && exit 1
 
 # ex: ts=2 sw=2 et filetype=sh

cc @gauravkghildiyal

@gauravkghildiyal
Copy link
Member

Thanks @dprotaso! I'll give this a shot

/assign

@gauravkghildiyal
Copy link
Member

/area gwctl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants