Skip to content

Commit ca11a8f

Browse files
Use code-generator for clientset, informers, listers (kubeflow#2563)
* Use code-generator to for clientset, informer, lister Signed-off-by: jbhalodia-slack <[email protected]> * Add README in hack/ for code-generator Signed-off-by: jbhalodia-slack <[email protected]> * Run verify-codegen.sh in tests Signed-off-by: jbhalodia-slack <[email protected]> * make generate Signed-off-by: jbhalodia-slack <[email protected]> * make build-api-docs Signed-off-by: jbhalodia-slack <[email protected]> * update makefile Signed-off-by: jbhalodia-slack <[email protected]> * update makefile Signed-off-by: jbhalodia-slack <[email protected]> * make go-fmt Signed-off-by: jbhalodia-slack <[email protected]> * make generate Signed-off-by: jbhalodia-slack <[email protected]> * run tests Signed-off-by: jbhalodia-slack <[email protected]> * Remove deepcopy-gen since its conflicting with controller-gen Signed-off-by: jbhalodia-slack <[email protected]> * Revert some changes Signed-off-by: jbhalodia-slack <[email protected]> * Generate packages in pkg/client/ Signed-off-by: jbhalodia-slack <[email protected]> * Update year to 2025 in boilerplate.go.txt Signed-off-by: jbhalodia-slack <[email protected]> * Update year to 2025 in types.go Signed-off-by: jbhalodia-slack <[email protected]> --------- Signed-off-by: jbhalodia-slack <[email protected]>
1 parent 818e34a commit ca11a8f

38 files changed

+2775
-969
lines changed

.github/workflows/integration.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ jobs:
4747
false
4848
fi
4949
50+
- name: Verify Codegen
51+
run: |
52+
make verify-codegen
53+
5054
- name: Run go fmt check
5155
run: |
5256
make go-fmt

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ GEN_CRD_API_REFERENCE_DOCS_VERSION ?= v0.3.0
6161
HELM_VERSION ?= v3.15.3
6262
HELM_UNITTEST_VERSION ?= 0.5.1
6363
HELM_DOCS_VERSION ?= v1.14.2
64+
CODE_GENERATOR_VERSION ?= v0.33.1
6465

6566
## Binaries
6667
SPARK_OPERATOR ?= $(LOCALBIN)/spark-operator
@@ -118,6 +119,14 @@ generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and
118119
update-crd: manifests ## Update CRD files in the Helm chart.
119120
cp config/crd/bases/* charts/spark-operator-chart/crds/
120121

122+
.PHONY: verify-codegen
123+
verify-codegen: $(LOCALBIN) ## Install code-generator commands and verify changes
124+
$(call go-install-tool,$(LOCALBIN)/register-gen-$(CODE_GENERATOR_VERSION),k8s.io/code-generator/cmd/register-gen,$(CODE_GENERATOR_VERSION))
125+
$(call go-install-tool,$(LOCALBIN)/client-gen-$(CODE_GENERATOR_VERSION),k8s.io/code-generator/cmd/client-gen,$(CODE_GENERATOR_VERSION))
126+
$(call go-install-tool,$(LOCALBIN)/lister-gen-$(CODE_GENERATOR_VERSION),k8s.io/code-generator/cmd/lister-gen,$(CODE_GENERATOR_VERSION))
127+
$(call go-install-tool,$(LOCALBIN)/informer-gen-$(CODE_GENERATOR_VERSION),k8s.io/code-generator/cmd/informer-gen,$(CODE_GENERATOR_VERSION))
128+
./hack/verify-codegen.sh
129+
121130
.PHONY: go-clean
122131
go-clean: ## Clean up caches and output.
123132
@echo "cleaning up caches and output"

api/v1beta2/scheduledsparkapplication_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ type ScheduledSparkApplicationStatus struct {
9191
// +kubebuilder:printcolumn:JSONPath=.status.lastRun,name=Last Run,type=date
9292
// +kubebuilder:printcolumn:JSONPath=.status.lastRunName,name=Last Run Name,type=string
9393
// +kubebuilder:printcolumn:JSONPath=.metadata.creationTimestamp,name=Age,type=date
94+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
95+
// +genclient
9496

9597
// ScheduledSparkApplication is the Schema for the scheduledsparkapplications API.
9698
type ScheduledSparkApplication struct {
@@ -102,6 +104,7 @@ type ScheduledSparkApplication struct {
102104
}
103105

104106
// +kubebuilder:object:root=true
107+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
105108

106109
// ScheduledSparkApplicationList contains a list of ScheduledSparkApplication.
107110
type ScheduledSparkApplicationList struct {

api/v1beta2/sparkapplication_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ type SparkApplicationStatus struct {
182182
// +kubebuilder:printcolumn:JSONPath=.status.lastSubmissionAttemptTime,name=Start,type=string
183183
// +kubebuilder:printcolumn:JSONPath=.status.terminationTime,name=Finish,type=string
184184
// +kubebuilder:printcolumn:JSONPath=.metadata.creationTimestamp,name=Age,type=date
185+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
186+
// +genclient
185187

186188
// SparkApplication is the Schema for the sparkapplications API
187189
type SparkApplication struct {
@@ -193,6 +195,7 @@ type SparkApplication struct {
193195
}
194196

195197
// +kubebuilder:object:root=true
198+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
196199

197200
// SparkApplicationList contains a list of SparkApplication
198201
type SparkApplicationList struct {

api/v1beta2/types.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2025 The Kubeflow authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
/*
18+
This file is needed for kubernetes/code-generator/kube_codegen.sh script used in hack/update-codegen.sh.
19+
*/
20+
21+
package v1beta2
22+
23+
//+genclient

api/v1beta2/zz_generated.deepcopy.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.

0 commit comments

Comments
 (0)