1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
package state
import (
"context"
"github.com/spf13/cobra"
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)
//go:generate mockgen -package state -destination command_helper_mocks.go . ActionWaiter,TokenEnsurer
type ActionWaiter interface {
ActionProgress(context.Context, *hcloud.Action) error
WaitForActions(context.Context, []*hcloud.Action) error
}
type TokenEnsurer interface {
EnsureToken(cmd *cobra.Command, args []string) error
}
func WrapCtx(
ctx context.Context,
fn func(context.Context, *cobra.Command, []string) error,
) func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
return fn(ctx, cmd, args)
}
}
|