From 7551f082040cc1c2d3953556869b1b9f3e54ea16 Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Mon, 4 Nov 2024 11:03:23 +0100 Subject: [PATCH] Fix panics in SetV1Beta2Conditions methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Büringer buringerst@vmware.com --- api/v1beta1/cluster_types.go | 2 +- api/v1beta1/clusterclass_types.go | 2 +- api/v1beta1/machine_types.go | 2 +- api/v1beta1/machinedeployment_types.go | 2 +- api/v1beta1/machinehealthcheck_types.go | 2 +- api/v1beta1/machineset_types.go | 2 +- bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go | 2 +- .../kubeadm/api/v1beta1/kubeadm_control_plane_types.go | 2 +- exp/addons/api/v1beta1/clusterresourceset_types.go | 2 +- exp/api/v1beta1/machinepool_types.go | 2 +- .../docker/api/v1beta1/dockercluster_types.go | 2 +- .../docker/api/v1beta1/dockermachine_types.go | 2 +- .../inmemory/api/v1alpha1/inmemorycluster_types.go | 2 +- .../inmemory/api/v1alpha1/inmemorymachine_types.go | 2 +- util/test/builder/v1beta2_transition.go | 6 +++--- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/api/v1beta1/cluster_types.go b/api/v1beta1/cluster_types.go index 82e3ec077b7e..4712da483162 100644 --- a/api/v1beta1/cluster_types.go +++ b/api/v1beta1/cluster_types.go @@ -651,7 +651,7 @@ func (c *Cluster) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (c *Cluster) SetV1Beta2Conditions(conditions []metav1.Condition) { - if c.Status.V1Beta2 == nil && conditions != nil { + if c.Status.V1Beta2 == nil { c.Status.V1Beta2 = &ClusterV1Beta2Status{} } c.Status.V1Beta2.Conditions = conditions diff --git a/api/v1beta1/clusterclass_types.go b/api/v1beta1/clusterclass_types.go index 4b1c5dba97b5..3c605f2d5519 100644 --- a/api/v1beta1/clusterclass_types.go +++ b/api/v1beta1/clusterclass_types.go @@ -1021,7 +1021,7 @@ func (c *ClusterClass) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (c *ClusterClass) SetV1Beta2Conditions(conditions []metav1.Condition) { - if c.Status.V1Beta2 == nil && conditions != nil { + if c.Status.V1Beta2 == nil { c.Status.V1Beta2 = &ClusterClassV1Beta2Status{} } c.Status.V1Beta2.Conditions = conditions diff --git a/api/v1beta1/machine_types.go b/api/v1beta1/machine_types.go index bb1d0f31765f..ec231469c77e 100644 --- a/api/v1beta1/machine_types.go +++ b/api/v1beta1/machine_types.go @@ -645,7 +645,7 @@ func (m *Machine) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (m *Machine) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil && conditions != nil { + if m.Status.V1Beta2 == nil { m.Status.V1Beta2 = &MachineV1Beta2Status{} } m.Status.V1Beta2.Conditions = conditions diff --git a/api/v1beta1/machinedeployment_types.go b/api/v1beta1/machinedeployment_types.go index 204576acfd0e..96e0bd9c6232 100644 --- a/api/v1beta1/machinedeployment_types.go +++ b/api/v1beta1/machinedeployment_types.go @@ -550,7 +550,7 @@ func (m *MachineDeployment) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (m *MachineDeployment) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil && conditions != nil { + if m.Status.V1Beta2 == nil { m.Status.V1Beta2 = &MachineDeploymentV1Beta2Status{} } m.Status.V1Beta2.Conditions = conditions diff --git a/api/v1beta1/machinehealthcheck_types.go b/api/v1beta1/machinehealthcheck_types.go index e2b62c738ebf..42c4817f0f15 100644 --- a/api/v1beta1/machinehealthcheck_types.go +++ b/api/v1beta1/machinehealthcheck_types.go @@ -224,7 +224,7 @@ func (m *MachineHealthCheck) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (m *MachineHealthCheck) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil && conditions != nil { + if m.Status.V1Beta2 == nil { m.Status.V1Beta2 = &MachineHealthCheckV1Beta2Status{} } m.Status.V1Beta2.Conditions = conditions diff --git a/api/v1beta1/machineset_types.go b/api/v1beta1/machineset_types.go index a20fd15f42f5..df85ea9a11af 100644 --- a/api/v1beta1/machineset_types.go +++ b/api/v1beta1/machineset_types.go @@ -365,7 +365,7 @@ func (m *MachineSet) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (m *MachineSet) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil && conditions != nil { + if m.Status.V1Beta2 == nil { m.Status.V1Beta2 = &MachineSetV1Beta2Status{} } m.Status.V1Beta2.Conditions = conditions diff --git a/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go b/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go index c9b62a9aad7b..ea2956d30857 100644 --- a/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go +++ b/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go @@ -501,7 +501,7 @@ func (c *KubeadmConfig) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (c *KubeadmConfig) SetV1Beta2Conditions(conditions []metav1.Condition) { - if c.Status.V1Beta2 == nil && conditions != nil { + if c.Status.V1Beta2 == nil { c.Status.V1Beta2 = &KubeadmConfigV1Beta2Status{} } c.Status.V1Beta2.Conditions = conditions diff --git a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go index e3ecfcc36403..7db4fcbf99ce 100644 --- a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go +++ b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go @@ -428,7 +428,7 @@ func (in *KubeadmControlPlane) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (in *KubeadmControlPlane) SetV1Beta2Conditions(conditions []metav1.Condition) { - if in.Status.V1Beta2 == nil && conditions != nil { + if in.Status.V1Beta2 == nil { in.Status.V1Beta2 = &KubeadmControlPlaneV1Beta2Status{} } in.Status.V1Beta2.Conditions = conditions diff --git a/exp/addons/api/v1beta1/clusterresourceset_types.go b/exp/addons/api/v1beta1/clusterresourceset_types.go index a061256044a3..780bd28c5627 100644 --- a/exp/addons/api/v1beta1/clusterresourceset_types.go +++ b/exp/addons/api/v1beta1/clusterresourceset_types.go @@ -141,7 +141,7 @@ func (m *ClusterResourceSet) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (m *ClusterResourceSet) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil && conditions != nil { + if m.Status.V1Beta2 == nil { m.Status.V1Beta2 = &ClusterResourceSetV1Beta2Status{} } m.Status.V1Beta2.Conditions = conditions diff --git a/exp/api/v1beta1/machinepool_types.go b/exp/api/v1beta1/machinepool_types.go index 1fa322767c96..14ac320f0cf3 100644 --- a/exp/api/v1beta1/machinepool_types.go +++ b/exp/api/v1beta1/machinepool_types.go @@ -283,7 +283,7 @@ func (m *MachinePool) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (m *MachinePool) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil && conditions != nil { + if m.Status.V1Beta2 == nil { m.Status.V1Beta2 = &MachinePoolV1Beta2Status{} } m.Status.V1Beta2.Conditions = conditions diff --git a/test/infrastructure/docker/api/v1beta1/dockercluster_types.go b/test/infrastructure/docker/api/v1beta1/dockercluster_types.go index 34dd32868c32..c450c83072be 100644 --- a/test/infrastructure/docker/api/v1beta1/dockercluster_types.go +++ b/test/infrastructure/docker/api/v1beta1/dockercluster_types.go @@ -159,7 +159,7 @@ func (c *DockerCluster) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (c *DockerCluster) SetV1Beta2Conditions(conditions []metav1.Condition) { - if c.Status.V1Beta2 == nil && conditions != nil { + if c.Status.V1Beta2 == nil { c.Status.V1Beta2 = &DockerClusterV1Beta2Status{} } c.Status.V1Beta2.Conditions = conditions diff --git a/test/infrastructure/docker/api/v1beta1/dockermachine_types.go b/test/infrastructure/docker/api/v1beta1/dockermachine_types.go index 552cc089b80b..edc8401cb678 100644 --- a/test/infrastructure/docker/api/v1beta1/dockermachine_types.go +++ b/test/infrastructure/docker/api/v1beta1/dockermachine_types.go @@ -154,7 +154,7 @@ func (c *DockerMachine) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (c *DockerMachine) SetV1Beta2Conditions(conditions []metav1.Condition) { - if c.Status.V1Beta2 == nil && conditions != nil { + if c.Status.V1Beta2 == nil { c.Status.V1Beta2 = &DockerMachineV1Beta2Status{} } c.Status.V1Beta2.Conditions = conditions diff --git a/test/infrastructure/inmemory/api/v1alpha1/inmemorycluster_types.go b/test/infrastructure/inmemory/api/v1alpha1/inmemorycluster_types.go index 4d5a5b8d173f..6429ee4d8052 100644 --- a/test/infrastructure/inmemory/api/v1alpha1/inmemorycluster_types.go +++ b/test/infrastructure/inmemory/api/v1alpha1/inmemorycluster_types.go @@ -111,7 +111,7 @@ func (c *InMemoryCluster) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (c *InMemoryCluster) SetV1Beta2Conditions(conditions []metav1.Condition) { - if c.Status.V1Beta2 == nil && conditions != nil { + if c.Status.V1Beta2 == nil { c.Status.V1Beta2 = &InMemoryClusterV1Beta2Status{} } c.Status.V1Beta2.Conditions = conditions diff --git a/test/infrastructure/inmemory/api/v1alpha1/inmemorymachine_types.go b/test/infrastructure/inmemory/api/v1alpha1/inmemorymachine_types.go index 0e2ec89244c3..a4a82b50a9a6 100644 --- a/test/infrastructure/inmemory/api/v1alpha1/inmemorymachine_types.go +++ b/test/infrastructure/inmemory/api/v1alpha1/inmemorymachine_types.go @@ -202,7 +202,7 @@ func (c *InMemoryMachine) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (c *InMemoryMachine) SetV1Beta2Conditions(conditions []metav1.Condition) { - if c.Status.V1Beta2 == nil && conditions != nil { + if c.Status.V1Beta2 == nil { c.Status.V1Beta2 = &InMemoryMachineV1Beta2Status{} } c.Status.V1Beta2.Conditions = conditions diff --git a/util/test/builder/v1beta2_transition.go b/util/test/builder/v1beta2_transition.go index 6536e976a604..0920620235ce 100644 --- a/util/test/builder/v1beta2_transition.go +++ b/util/test/builder/v1beta2_transition.go @@ -162,7 +162,7 @@ func (o *Phase1Obj) GetV1Beta2Conditions() []metav1.Condition { // SetV1Beta2Conditions sets conditions for an API object. func (o *Phase1Obj) SetV1Beta2Conditions(conditions []metav1.Condition) { - if o.Status.V1Beta2 == nil && conditions != nil { + if o.Status.V1Beta2 == nil { o.Status.V1Beta2 = &Phase1ObjStatusV1Beta2{} } o.Status.V1Beta2.Conditions = conditions @@ -233,10 +233,10 @@ func (o *Phase2Obj) GetConditions() clusterv1.Conditions { // SetConditions sets the conditions on this object. func (o *Phase2Obj) SetConditions(conditions clusterv1.Conditions) { - if o.Status.Deprecated == nil && conditions != nil { + if o.Status.Deprecated == nil { o.Status.Deprecated = &Phase2ObjStatusDeprecated{V1Beta1: &Phase2ObjStatusDeprecatedV1Beta1{}} } - if o.Status.Deprecated.V1Beta1 == nil && conditions != nil { + if o.Status.Deprecated.V1Beta1 == nil { o.Status.Deprecated.V1Beta1 = &Phase2ObjStatusDeprecatedV1Beta1{} } o.Status.Deprecated.V1Beta1.Conditions = conditions