Skip to content

Commit

Permalink
Fix a bug in ClusterClient's GetClusterObjects() and GetMachineObject…
Browse files Browse the repository at this point in the history
…s() (#321)

The previous implementation took the address of the iteration variable. While the value of the iteration value changes on each iteration, the address does not change for the entirety of the loop. Previously, the slice returned by these functions would be a collection of the exact same iterator variable address and which of course would be filled with a value of the last value in the loop iteration.
  • Loading branch information
spew authored and k8s-ci-robot committed Jun 11, 2018
1 parent ee9a08e commit 7fdecc5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clusterctl/clusterdeployer/clusterclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func (c *clusterClient) GetClusterObjects() ([]*clusterv1.Cluster, error) {
return nil, err
}

for _, cluster := range clusterlist.Items {
clusters = append(clusters, &cluster)
for i := 0; i < len(clusterlist.Items); i++ {
clusters = append(clusters, &clusterlist.Items[i])
}
return clusters, nil
}
Expand All @@ -109,8 +109,8 @@ func (c *clusterClient) GetMachineObjects() ([]*clusterv1.Machine, error) {
return nil, err
}

for _, machine := range machineslist.Items {
machines = append(machines, &machine)
for i := 0; i < len(machineslist.Items); i++ {
machines = append(machines, &machineslist.Items[i])
}
return machines, nil
}
Expand Down

0 comments on commit 7fdecc5

Please sign in to comment.