-
Notifications
You must be signed in to change notification settings - Fork 370
/
types.go
80 lines (64 loc) · 2.35 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package types
import (
synccontext "github.com/loft-sh/vcluster/pkg/controllers/syncer/context"
"github.com/loft-sh/vcluster/pkg/controllers/syncer/translator"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
)
type Object interface {
Name() string
Resource() client.Object
}
type Exporter interface {
Name() string
Register()
}
type Syncer interface {
Object
translator.NameTranslator
// SyncDown is called when a virtual object was created and needs to be synced down to the physical cluster
SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error)
// Sync is called to sync a virtual object with a physical object
Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error)
}
type UpSyncer interface {
// SyncUp is called when a physical object exists but the virtual object does not exist
SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error)
}
type FakeSyncer interface {
Object
FakeSyncUp(ctx *synccontext.SyncContext, req types.NamespacedName) (ctrl.Result, error)
FakeSync(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error)
}
type Starter interface {
ReconcileStart(ctx *synccontext.SyncContext, req ctrl.Request) (bool, error)
ReconcileEnd()
}
// IndicesRegisterer registers additional indices for the controller
type IndicesRegisterer interface {
RegisterIndices(ctx *synccontext.RegisterContext) error
}
// ControllerModifier is used to modify the created controller for the syncer
type ControllerModifier interface {
ModifyController(ctx *synccontext.RegisterContext, builder *builder.Builder) (*builder.Builder, error)
}
// Initializer is used to create and update the prerequisites of the syncer before the controller is started
type Initializer interface {
Init(registerContext *synccontext.RegisterContext) error
}
type Options struct {
// DisableUIDDeletion disables automatic deletion of physical objects if the uid between physical
// and virtual doesn't match anymore.
DisableUIDDeletion bool
IsClusterScopedCRD bool
HasStatusSubresource bool
}
type OptionsProvider interface {
WithOptions() *Options
}
type ObjectExcluder interface {
ExcludeVirtual(vObj client.Object) bool
ExcludePhysical(vObj client.Object) bool
}