mirror of
https://github.com/apricote/hcloud-upload-image.git
synced 2026-01-13 21:31:03 +00:00
25 lines
638 B
Go
25 lines
638 B
Go
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
|
|
}
|