forked from loft-sh/vcluster-sdk
/
types.go
53 lines (42 loc) · 1.77 KB
/
types.go
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package hook
import (
"context"
"github.com/TylerGillson/vcluster-sdk/syncer"
"sigs.k8s.io/controller-runtime/pkg/client"
)
// ClientHook tells the sdk that this action watches on certain vcluster requests and wants
// to mutate these. The objects this action wants to watch can be defined through the
// Resource() function that returns a new object of the type to watch. By implementing
// the defined interfaces below it is possible to watch on:
// Create, Update (includes patch requests), Delete and Get requests.
// This makes it possible to change incoming or outgoing objects on the fly, without the
// need to completely replace a vanilla vcluster syncer.
type ClientHook interface {
syncer.Base
// Resource is the typed resource (e.g. &corev1.Pod{}) that should get mutated.
Resource() client.Object
}
type MutateCreateVirtual interface {
MutateCreateVirtual(ctx context.Context, obj client.Object) (client.Object, error)
}
type MutateUpdateVirtual interface {
MutateUpdateVirtual(ctx context.Context, obj client.Object) (client.Object, error)
}
type MutateDeleteVirtual interface {
MutateDeleteVirtual(ctx context.Context, obj client.Object) (client.Object, error)
}
type MutateGetVirtual interface {
MutateGetVirtual(ctx context.Context, obj client.Object) (client.Object, error)
}
type MutateCreatePhysical interface {
MutateCreatePhysical(ctx context.Context, obj client.Object) (client.Object, error)
}
type MutateUpdatePhysical interface {
MutateUpdatePhysical(ctx context.Context, obj client.Object) (client.Object, error)
}
type MutateDeletePhysical interface {
MutateDeletePhysical(ctx context.Context, obj client.Object) (client.Object, error)
}
type MutateGetPhysical interface {
MutateGetPhysical(ctx context.Context, obj client.Object) (client.Object, error)
}