Skip to content

Commit

Permalink
Add vscode integration for golangci-kal
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelSpeed committed Dec 4, 2024
1 parent 670a3d3 commit 1c99bcf
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ linters:
disable-all: true
enable:
- kal
issues:
# We have a lot of existing issues.
# Want to make sure that those adding new fields have an
# opportunity to fix them when running the linter locally.
max-issues-per-linter: 1000
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"go.lintTool": "golangci-lint",
"go.alternateTools": {
"golangci-lint": "${workspaceFolder}/hack/golangci-lint.sh",
}
}
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ update-codegen-crds: update-scripts
#
#####################

# When not otherwise set, diff/lint against the local master branch
PULL_BASE_SHA ?= master

.PHONY: lint
lint:
hack/golangci-lint.sh run --new-from-rev=${PULL_BASE_SHA}

.PHONY: verify-scripts
verify-scripts:
bash -x hack/verify-deepcopy.sh
Expand All @@ -56,7 +63,7 @@ verify-scripts:
hack/verify-promoted-features-pass-tests.sh

.PHONY: verify
verify: verify-scripts verify-crd-schema verify-codegen-crds
verify: verify-scripts lint verify-crd-schema verify-codegen-crds

.PHONY: verify-codegen-crds
verify-codegen-crds:
Expand Down
18 changes: 18 additions & 0 deletions hack/golangci-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

source "$(dirname "${BASH_SOURCE}")/lib/init.sh"

# Build codegen-crds when it's not present and not overriden for a specific file.
if [ -z "${GOLANGCI_LINT:-}" ];then
${TOOLS_MAKE} golangci-kal
GOLANGCI_LINT="${TOOLS_OUTPUT}/golangci-kal"
fi

# In CI, HOME is set to / and is not writable.
# Make sure golangci-lint can create its cache.
HOME=${HOME:-"/tmp"}
if [[ ${HOME} == "/" ]]; then
HOME="/tmp"
fi

"${GOLANGCI_LINT}" $@

0 comments on commit 1c99bcf

Please sign in to comment.