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
package clusterprovider
import (
"context"
"errors"
"time"
)
var ErrAwaitTimeout = errors.New("clusterprovider: the condition did not hold in time")
type Objects[T any] interface {
Get(ctx context.Context, name string) (*T, error)
List(ctx context.Context, labelSelector string) ([]T, error)
Create(ctx context.Context, obj *T) error
Update(ctx context.Context, obj *T) error
Delete(ctx context.Context, name string) error
Await(ctx context.Context, name string, timeout time.Duration, done func(obj *T) (bool, error)) (*T, error)
AwaitSelected(ctx context.Context, labelSelector string, timeout time.Duration, done func(objs []T) (bool, error)) error
}
func absent[T any](obj *T) (bool, error) { return obj == nil, nil }