From 8f0ff2d5ddb732e08e14dae41febe76a65d9a798 Mon Sep 17 00:00:00 2001 From: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com> Date: Wed, 18 Oct 2023 12:22:44 -0400 Subject: [PATCH] Revert "Fix: run `make update` fail because deepcopy doesn't support generic type. (#288)" This reverts commit ae208c861684c3f7cc7d46471ebf2bf1c7f85ae1. Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com> --- cluster/v1alpha1/doc.go | 1 + cluster/v1alpha1/helpers.go | 2 -- cluster/v1alpha1/types.go | 3 --- cluster/v1alpha1/types_addonplacementscore.go | 4 ---- cluster/v1alpha1/types_rolloutstrategy.go | 7 ------- cluster/v1alpha1/zz_generated.deepcopy.go | 15 ++++----------- 6 files changed, 5 insertions(+), 27 deletions(-) diff --git a/cluster/v1alpha1/doc.go b/cluster/v1alpha1/doc.go index b435a9cf7..28765f356 100644 --- a/cluster/v1alpha1/doc.go +++ b/cluster/v1alpha1/doc.go @@ -1,4 +1,5 @@ // Package v1alpha1 contains API Schema definitions for the cluster v1alpha1 API group +// +k8s:deepcopy-gen=package,register // +k8s:conversion-gen=open-cluster-management.io/api/cluster // +k8s:defaulter-gen=TypeMeta // +k8s:openapi-gen=true diff --git a/cluster/v1alpha1/helpers.go b/cluster/v1alpha1/helpers.go index 03c2abd5b..9d25e05d5 100644 --- a/cluster/v1alpha1/helpers.go +++ b/cluster/v1alpha1/helpers.go @@ -38,7 +38,6 @@ const ( ) // ClusterRolloutStatus holds the rollout status information for a cluster. -// +k8s:deepcopy-gen=true type ClusterRolloutStatus struct { // cluster name ClusterName string @@ -54,7 +53,6 @@ type ClusterRolloutStatus struct { } // RolloutResult contains list of clusters that are timeOut, removed and required to rollOut -// +k8s:deepcopy-gen=true type RolloutResult struct { // ClustersToRollout is a slice of ClusterRolloutStatus that will be rolled out. ClustersToRollout []ClusterRolloutStatus diff --git a/cluster/v1alpha1/types.go b/cluster/v1alpha1/types.go index ab3d5c010..6cb57bc3b 100644 --- a/cluster/v1alpha1/types.go +++ b/cluster/v1alpha1/types.go @@ -7,7 +7,6 @@ import ( // +genclient // +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:deepcopy-gen=true // +kubebuilder:resource:scope="Cluster" // ClusterClaim represents cluster information that a managed cluster claims @@ -26,7 +25,6 @@ type ClusterClaim struct { Spec ClusterClaimSpec `json:"spec,omitempty"` } -// +k8s:deepcopy-gen=true type ClusterClaimSpec struct { // Value is a claim-dependent string // +kubebuilder:validation:MaxLength=1024 @@ -35,7 +33,6 @@ type ClusterClaimSpec struct { } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:deepcopy-gen=true // ClusterClaimList is a collection of ClusterClaim. type ClusterClaimList struct { diff --git a/cluster/v1alpha1/types_addonplacementscore.go b/cluster/v1alpha1/types_addonplacementscore.go index 8dc98bf25..1ce73580b 100644 --- a/cluster/v1alpha1/types_addonplacementscore.go +++ b/cluster/v1alpha1/types_addonplacementscore.go @@ -6,7 +6,6 @@ import ( // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:deepcopy-gen=true // +kubebuilder:resource:scope="Namespaced" // +kubebuilder:subresource:status @@ -22,7 +21,6 @@ type AddOnPlacementScore struct { } // AddOnPlacementScoreStatus represents the current status of AddOnPlacementScore. -// +k8s:deepcopy-gen=true type AddOnPlacementScoreStatus struct { // Conditions contain the different condition statuses for this AddOnPlacementScore. // +patchMergeKey=type @@ -48,7 +46,6 @@ type AddOnPlacementScoreStatus struct { } // AddOnPlacementScoreItem represents the score name and value. -// +k8s:deepcopy-gen=true type AddOnPlacementScoreItem struct { // Name is the name of the score // +kubebuilder:validation:Required @@ -64,7 +61,6 @@ type AddOnPlacementScoreItem struct { } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:deepcopy-gen=true // AddOnPlacementScoreList is a collection of AddOnPlacementScore. type AddOnPlacementScoreList struct { diff --git a/cluster/v1alpha1/types_rolloutstrategy.go b/cluster/v1alpha1/types_rolloutstrategy.go index 0e3da1aaa..c9fa38155 100644 --- a/cluster/v1alpha1/types_rolloutstrategy.go +++ b/cluster/v1alpha1/types_rolloutstrategy.go @@ -18,7 +18,6 @@ const ( ) // Rollout strategy to apply workload to the selected clusters by Placement and DecisionStrategy. -// +k8s:deepcopy-gen=true type RolloutStrategy struct { // Rollout strategy Types are All, Progressive and ProgressivePerGroup // 1) All means apply the workload to all clusters in the decision groups at once. @@ -43,7 +42,6 @@ type RolloutStrategy struct { } // Timeout to consider while applying the workload. -// +k8s:deepcopy-gen=true type Timeout struct { // Timeout define how long workload applier controller will wait till workload reach successful state in the cluster. // Timeout default value is None meaning the workload applier will not proceed apply workload to other clusters if did not reach the successful state. @@ -56,7 +54,6 @@ type Timeout struct { // MandatoryDecisionGroup set the decision group name or group index. // GroupName is considered first to select the decisionGroups then GroupIndex. -// +k8s:deepcopy-gen=true type MandatoryDecisionGroup struct { // GroupName of the decision group should match the placementDecisions label value with label key cluster.open-cluster-management.io/decision-group-name // +optional @@ -68,7 +65,6 @@ type MandatoryDecisionGroup struct { } // MandatoryDecisionGroups -// +k8s:deepcopy-gen=true type MandatoryDecisionGroups struct { // List of the decision groups names or indexes to apply the workload first and fail if workload did not reach successful state. // GroupName or GroupIndex must match with the decisionGroups defined in the placement's decisionStrategy @@ -77,14 +73,12 @@ type MandatoryDecisionGroups struct { } // RolloutAll is a RolloutStrategy Type -// +k8s:deepcopy-gen=true type RolloutAll struct { // +optional Timeout `json:",inline"` } // RolloutProgressivePerGroup is a RolloutStrategy Type -// +k8s:deepcopy-gen=true type RolloutProgressivePerGroup struct { // +optional MandatoryDecisionGroups `json:",inline"` @@ -94,7 +88,6 @@ type RolloutProgressivePerGroup struct { } // RolloutProgressive is a RolloutStrategy Type -// +k8s:deepcopy-gen=true type RolloutProgressive struct { // +optional MandatoryDecisionGroups `json:",inline"` diff --git a/cluster/v1alpha1/zz_generated.deepcopy.go b/cluster/v1alpha1/zz_generated.deepcopy.go index fcdd36c0c..00938a885 100644 --- a/cluster/v1alpha1/zz_generated.deepcopy.go +++ b/cluster/v1alpha1/zz_generated.deepcopy.go @@ -316,22 +316,15 @@ func (in *RolloutResult) DeepCopyInto(out *RolloutResult) { if in.ClustersToRollout != nil { in, out := &in.ClustersToRollout, &out.ClustersToRollout *out = make([]ClusterRolloutStatus, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() } } if in.ClustersTimeOut != nil { in, out := &in.ClustersTimeOut, &out.ClustersTimeOut *out = make([]ClusterRolloutStatus, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.ClustersRemoved != nil { - in, out := &in.ClustersRemoved, &out.ClustersRemoved - *out = make([]ClusterRolloutStatus, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() } } return