Skip to content

Commit

Permalink
clusterclass: fix nil pointer for empty workers in webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Sep 19, 2024
1 parent f9738ac commit 9173f28
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions internal/webhooks/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -772,17 +772,19 @@ func DefaultAndValidateVariables(ctx context.Context, cluster, oldCluster *clust
oldCPOverrides = oldCluster.Spec.Topology.ControlPlane.Variables.Overrides
}

oldMDVariables = make(map[string][]clusterv1.ClusterVariable, len(oldCluster.Spec.Topology.Workers.MachineDeployments))
for _, md := range oldCluster.Spec.Topology.Workers.MachineDeployments {
if md.Variables != nil {
oldMDVariables[md.Name] = md.Variables.Overrides
if oldCluster.Spec.Topology.Workers != nil {
oldMDVariables = make(map[string][]clusterv1.ClusterVariable, len(oldCluster.Spec.Topology.Workers.MachineDeployments))
for _, md := range oldCluster.Spec.Topology.Workers.MachineDeployments {
if md.Variables != nil {
oldMDVariables[md.Name] = md.Variables.Overrides
}
}
}

oldMPVariables = make(map[string][]clusterv1.ClusterVariable, len(oldCluster.Spec.Topology.Workers.MachinePools))
for _, mp := range oldCluster.Spec.Topology.Workers.MachinePools {
if mp.Variables != nil {
oldMPVariables[mp.Name] = mp.Variables.Overrides
oldMPVariables = make(map[string][]clusterv1.ClusterVariable, len(oldCluster.Spec.Topology.Workers.MachinePools))
for _, mp := range oldCluster.Spec.Topology.Workers.MachinePools {
if mp.Variables != nil {
oldMPVariables[mp.Name] = mp.Variables.Overrides
}
}
}
}
Expand Down

0 comments on commit 9173f28

Please sign in to comment.