feat: documentation and cleanup command

This commit is contained in:
Julian Tölle 2024-05-04 22:13:33 +02:00
parent 27d4e3240e
commit c9ab40b539
16 changed files with 394 additions and 148 deletions

View file

@ -0,0 +1,25 @@
package actionutil
import (
"context"
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)
func Settle(ctx context.Context, client hcloud.IActionClient, actions ...*hcloud.Action) (successActions []*hcloud.Action, errorActions []*hcloud.Action, err error) {
err = client.WaitForFunc(ctx, func(update *hcloud.Action) error {
switch update.Status {
case hcloud.ActionStatusSuccess:
successActions = append(successActions, update)
case hcloud.ActionStatusError:
errorActions = append(errorActions, update)
}
return nil
}, actions...)
if err != nil {
return nil, nil, err
}
return successActions, errorActions, nil
}