Skip to content

Commit

Permalink
fix(qemu): Prevent possible duplicate and nil-exception list (#1324)
Browse files Browse the repository at this point in the history
Reviewed-by: Cezar Craciunoiu <[email protected]>
Approved-by: Cezar Craciunoiu <[email protected]>
  • Loading branch information
craciunoiuc authored Feb 28, 2024
2 parents 27eeb87 + 24d8e07 commit fc799ff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions machine/qemu/v1alpha1.go
Original file line number Diff line number Diff line change
Expand Up @@ -902,17 +902,17 @@ func (service *machineV1alpha1Service) Get(ctx context.Context, machine *machine
// List implements kraftkit.sh/api/machine/v1alpha1.MachineService.List
func (service *machineV1alpha1Service) List(ctx context.Context, machines *machinev1alpha1.MachineList) (*machinev1alpha1.MachineList, error) {
cached := machines.Items
machines.Items = make([]zip.Object[machinev1alpha1.MachineSpec, machinev1alpha1.MachineStatus], len(cached))
machines.Items = []zip.Object[machinev1alpha1.MachineSpec, machinev1alpha1.MachineStatus]{}

// Iterate through each machine and grab the latest status
for i, machine := range cached {
for _, machine := range cached {
machine, err := service.Get(ctx, &machine)
if err != nil {
machines.Items = cached
return machines, err
}

machines.Items[i] = *machine
machines.Items = append(machines.Items, *machine)
}

return machines, nil
Expand Down

0 comments on commit fc799ff

Please sign in to comment.