Skip to content

Commit 7c017f5

Browse files
committed
Add the ability to fix linter issues
1 parent 1c99bcf commit 7c017f5

31 files changed

+4521
-3
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ PULL_BASE_SHA ?= master
4646
lint:
4747
hack/golangci-lint.sh run --new-from-rev=${PULL_BASE_SHA}
4848

49+
# While https://github.com/golangci/golangci-lint/issues/1779 is not fixed,
50+
# we need to run the fix separately from the lint command.
51+
# GolangCI-Lint will not actually run the fixer for us.
52+
# In the future we can remove this and have the linter auto-fix.
53+
.PHONY: lint-fix
54+
lint-fix:
55+
hack/lint-fix.sh
56+
4957
.PHONY: verify-scripts
5058
verify-scripts:
5159
bash -x hack/verify-deepcopy.sh

hack/lint-fix.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
4+
5+
# Build codegen-crds when it's not present and not overriden for a specific file.
6+
if [ -z "${KAL:-}" ];then
7+
${TOOLS_MAKE} kal
8+
KAL="${TOOLS_OUTPUT}/kal"
9+
fi
10+
11+
"${KAL}" -fix ./...

tools/Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ publish-kubebuilder-tools:
4646
.PHONY:codegen
4747
codegen: $(OUTPUT_DIR)/codegen
4848

49-
.PHONY:prerelease-lifecycle-gen
50-
prerelease-lifecycle-gen: $(OUTPUT_DIR)/prerelease-lifecycle-gen
51-
5249
.PHONY:controller-gen
5350
controller-gen: $(OUTPUT_DIR)/controller-gen
5451

@@ -61,9 +58,15 @@ go-to-protobuf: $(OUTPUT_DIR)/go-to-protobuf
6158
.PHONY:golangci-kal
6259
golangci-kal: $(OUTPUT_DIR)/golangci-kal
6360

61+
.PHONY:kal
62+
kal: $(OUTPUT_DIR)/kal
63+
6464
.PHONY:openapi-gen
6565
openapi-gen: $(OUTPUT_DIR)/openapi-gen
6666

67+
.PHONY:prerelease-lifecycle-gen
68+
prerelease-lifecycle-gen: $(OUTPUT_DIR)/prerelease-lifecycle-gen
69+
6770
.PHONY:protoc-gen-gogo
6871
protoc-gen-gogo: $(OUTPUT_DIR)/protoc-gen-gogo
6972

@@ -111,6 +114,9 @@ $(OUTPUT_DIR)/golangci-kal: $(OUTPUT_DIR)/vendor-version $(OUTPUT_DIR)/golangci-
111114
@ mv bin/golangci-kal $(OUTPUT_DIR)/golangci-kal
112115
@ rmdir bin
113116

117+
$(OUTPUT_DIR)/kal: $(OUTPUT_DIR)/vendor-version
118+
go build -mod=vendor -o $(OUTPUT_DIR)/kal ./vendor/github.com/JoelSpeed/kal/cmd/kal
119+
114120
$(OUTPUT_DIR)/openapi-gen: $(OUTPUT_DIR)/vendor-version
115121
go build -mod=vendor -o $(OUTPUT_DIR)/openapi-gen ./vendor/k8s.io/code-generator/cmd/openapi-gen
116122

tools/tools.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package tools
55

66
import (
77
_ "github.com/JoelSpeed/kal"
8+
_ "github.com/JoelSpeed/kal/cmd/kal"
89
_ "github.com/gogo/protobuf/gogoproto"
910
_ "github.com/gogo/protobuf/proto"
1011
_ "github.com/gogo/protobuf/sortkeys"

tools/vendor/github.com/JoelSpeed/kal/cmd/kal/main.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)