Skip to content

Commit

Permalink
Use controller-gen for deepcopy cluster:v1alpha1
Browse files Browse the repository at this point in the history
GenGo isn't respecting the `+k8s:deepcopy-gen=false` tag to skip
generation for the generic type

Signed-off-by: Dale Haiducek <[email protected]>
  • Loading branch information
dhaiducek committed Oct 26, 2023
1 parent 8f0ff2d commit baf4645
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ verify: check-env verify-scripts verify-codegen-crds verify-gocilint

update-scripts:
hack/update-deepcopy.sh
# Using controller-gen as a workaround for cluster:v1alpha1 because gengo
# isn't respecting deepcopy-gen:false nor does it support generics
# Issue: https://github.com/kubernetes/gengo/issues/225
$(CONTROLLER_GEN) object:headerFile="hack/empty.txt" paths="./cluster/v1alpha1"
hack/update-swagger-docs.sh
hack/update-codegen.sh
hack/update-v1beta1-crds.sh
Expand Down
1 change: 1 addition & 0 deletions cluster/v1alpha1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type RolloutResult struct {
}

// ClusterRolloutStatusFunc defines a function that return the rollout status for a given workload.
// +k8s:deepcopy-gen=false
type ClusterRolloutStatusFunc[T any] func(clusterName string, workload T) (ClusterRolloutStatus, error)

// The RolloutHandler required workload type (interface/struct) to be assigned to the generic type.
Expand Down
37 changes: 14 additions & 23 deletions cluster/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion hack/update-deepcopy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-ge

verify="${VERIFY:-}"

# cluster:v1alpha1 is generated in the Makefile target 'update-scripts' using controller-gen
# because gengo isn't respecting deepcopy-gen:false nor does it support generics
# Issue: https://github.com/kubernetes/gengo/issues/225
GOFLAGS="" bash ${CODEGEN_PKG}/generate-groups.sh "deepcopy" \
open-cluster-management.io/api/generated \
open-cluster-management.io/api \
"cluster:v1 cluster:v1alpha1 cluster:v1beta1 cluster:v1beta2 work:v1alpha1 work:v1 operator:v1 addon:v1alpha1" \
"cluster:v1 cluster:v1beta1 cluster:v1beta2 work:v1alpha1 work:v1 operator:v1 addon:v1alpha1" \
--go-header-file ${SCRIPT_ROOT}/hack/empty.txt \
${verify}

0 comments on commit baf4645

Please sign in to comment.