Skip to content

Commit 040724b

Browse files
committed
Move kube-api-linter to a go-plugin integration
1 parent fdb699f commit 040724b

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

.golangci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ linters:
66
settings:
77
custom:
88
kubeapilinter:
9-
type: module
9+
path: tools/_output/bin/kube-api-linter.so
1010
description: kubeapilinter is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices.
1111
settings:
1212
linters:

hack/golangci-lint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
44

55
# Build codegen-crds when it's not present and not overriden for a specific file.
66
if [ -z "${GOLANGCI_LINT:-}" ];then
7-
${TOOLS_MAKE} golangci-kube-api-linter
8-
GOLANGCI_LINT="${TOOLS_OUTPUT}/golangci-kube-api-linter"
7+
${TOOLS_MAKE} golangci-lint kube-api-linter
8+
GOLANGCI_LINT="${TOOLS_OUTPUT}/golangci-lint"
99
fi
1010

1111
# In CI, HOME is set to / and is not writable.

tools/.custom-gcl.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

tools/Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ deepcopy-gen: $(OUTPUT_DIR)/deepcopy-gen
5757
.PHONY:go-to-protobuf
5858
go-to-protobuf: $(OUTPUT_DIR)/go-to-protobuf
5959

60-
.PHONY:golangci-kube-api-linter
61-
golangci-kube-api-linter: $(OUTPUT_DIR)/golangci-kube-api-linter
60+
.PHONY:golangci-lint
61+
golangci-lint: $(OUTPUT_DIR)/golangci-lint
62+
63+
.PHONY:kube-api-linter
64+
kube-api-linter: $(OUTPUT_DIR)/kube-api-linter.so
6265

6366
.PHONY:openapi-gen
6467
openapi-gen: $(OUTPUT_DIR)/openapi-gen
@@ -107,11 +110,9 @@ $(OUTPUT_DIR)/go-to-protobuf: $(OUTPUT_DIR)/vendor-version
107110
$(OUTPUT_DIR)/golangci-lint: $(OUTPUT_DIR)/vendor-version
108111
go build -mod=vendor -o $(OUTPUT_DIR)/golangci-lint ./vendor/github.com/golangci/golangci-lint/v2/cmd/golangci-lint
109112

110-
# The golangci-lint custom command relies on finding a module, this uses a workaround to init the go.mod in the kal directory.
111-
$(OUTPUT_DIR)/golangci-kube-api-linter: $(OUTPUT_DIR)/vendor-version $(OUTPUT_DIR)/golangci-lint
112-
GOFLAGS=-mod=readonly $(OUTPUT_DIR)/golangci-lint custom
113-
@ mv bin/golangci-kube-api-linter $(OUTPUT_DIR)/golangci-kube-api-linter
114-
@ rmdir bin
113+
$(OUTPUT_DIR)/kube-api-linter.so: $(OUTPUT_DIR)/vendor-version
114+
go build -mod=vendor -buildmode=plugin -o $(OUTPUT_DIR)/kube-api-linter.so ./vendor/sigs.k8s.io/kube-api-linter/pkg/plugin
115+
ln -fs $(OUTPUT_DIR)/kube-api-linter.so $(TOOLS_DIR)/_output/bin/kube-api-linter.so
115116

116117
$(OUTPUT_DIR)/openapi-gen: $(OUTPUT_DIR)/vendor-version
117118
go build -mod=vendor -o $(OUTPUT_DIR)/openapi-gen ./vendor/k8s.io/code-generator/cmd/openapi-gen

tools/tools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ import (
1515
_ "k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo"
1616
_ "k8s.io/code-generator/cmd/prerelease-lifecycle-gen"
1717
_ "sigs.k8s.io/controller-tools/cmd/controller-gen"
18-
_ "sigs.k8s.io/kube-api-linter"
18+
_ "sigs.k8s.io/kube-api-linter/pkg/plugin"
1919
)

0 commit comments

Comments
 (0)