Skip to content

Commit 354de2d

Browse files
committed
Use go run for codegen and improve Makefile
Signed-off-by: Dyanngg <[email protected]>
1 parent 7be0b2b commit 354de2d

31 files changed

+86
-36
lines changed

Makefile

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,61 @@ help: ## Display this help.
2323

2424
##@ Development
2525

26+
CLIENTSET_NAME ?= versioned
27+
CLIENTSET_PKG_NAME ?= clientset
28+
API_PKG ?= sigs.k8s.io/network-policy-api
29+
API_GROUP_NAME ?= policy.networking.k8s.io
30+
API_DIR ?= ${API_PKG}/apis/v1alpha1
31+
OUTPUT_PKG ?= sigs.k8s.io/network-policy-api/client
32+
COMMON_FLAGS ?= --go-header-file $(shell pwd)/hack/boilerplate.go.txt
33+
34+
.PHONY: manifests
2635
manifests: ## Generate ClusterRole and CustomResourceDefinition objects.
2736
go run sigs.k8s.io/controller-tools/cmd/controller-gen rbac:roleName=manager-role crd paths=./apis/... output:crd:dir=./config/crd/bases output:stdout
2837

29-
generate: ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
30-
go run sigs.k8s.io/controller-tools/cmd/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
31-
38+
.PHONY: fmt
3239
fmt: ## Run go fmt against code.
3340
go fmt ./...
3441

42+
.PHONY: vet
3543
vet: ## Run go vet against code.
3644
go vet ./...
3745

46+
.PHONY: generate
47+
generate: generate-deepcopy generate-typed-clients generate-typed-listers generate-typed-informers
48+
49+
.PHONY: generate-deepcopy
50+
generate-deepcopy: ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
51+
go run sigs.k8s.io/controller-tools/cmd/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
52+
53+
.PHONY: generate-typed-clients
54+
generate-typed-clients: ## Generate typed client code
55+
go run k8s.io/code-generator/cmd/client-gen \
56+
--clientset-name "${CLIENTSET_NAME}" \
57+
--input-base "" \
58+
--input "${API_DIR}" \
59+
--output-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME}" \
60+
${COMMON_FLAGS}
61+
62+
.PHONY: generate-typed-listers
63+
generate-typed-listers: ## Generate typed listers code
64+
go run k8s.io/code-generator/cmd/lister-gen \
65+
--input-dirs "${API_DIR}" \
66+
--output-package "${OUTPUT_PKG}/listers" \
67+
${COMMON_FLAGS}
68+
69+
.PHONY: generate-typed-informers
70+
generate-typed-informers: ## Generate typed informers code
71+
go run k8s.io/code-generator/cmd/informer-gen \
72+
--input-dirs "${API_DIR}" \
73+
--versioned-clientset-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME}/${CLIENTSET_NAME}" \
74+
--listers-package "${OUTPUT_PKG}/listers" \
75+
--output-package "${OUTPUT_PKG}/informers" \
76+
${COMMON_FLAGS}
77+
3878
all: generate manifests fmt vet ## Runs all the development targets
3979

80+
.PHONY: verify
4081
verify:
4182
hack/verify-all.sh -v
4283

File renamed without changes.

bin/golangci-lint

25.3 MB
Binary file not shown.

client/clientset/versioned/clientset.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/clientset/versioned/fake/clientset_generated.go

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

0 commit comments

Comments
 (0)