From 8c8af90f98151ee8fdd4d929f6ecbb26e943c146 Mon Sep 17 00:00:00 2001 From: Jonas L Date: Wed, 19 Jun 2024 12:01:24 +0200 Subject: [PATCH] feat: filter out nil actions in action waiter (#464) Filter out nil actions, to help users of the function. --- hcloud/action_waiter.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hcloud/action_waiter.go b/hcloud/action_waiter.go index b14815e7..18f32c80 100644 --- a/hcloud/action_waiter.go +++ b/hcloud/action_waiter.go @@ -21,6 +21,9 @@ var _ ActionWaiter = (*ActionClient)(nil) // // The handleUpdate callback is called every time an action is updated. func (c *ActionClient) WaitForFunc(ctx context.Context, handleUpdate func(update *Action) error, actions ...*Action) error { + // Filter out nil actions + actions = slices.DeleteFunc(actions, func(a *Action) bool { return a == nil }) + running := make(map[int]struct{}, len(actions)) for _, action := range actions { if action.Status == ActionStatusRunning {