-
Notifications
You must be signed in to change notification settings - Fork 365
/
context.go
46 lines (36 loc) · 1.22 KB
/
context.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
package context
import (
"context"
controllercontext "github.com/loft-sh/vcluster/cmd/vcluster/context"
"github.com/loft-sh/vcluster/pkg/util/loghelper"
"k8s.io/apimachinery/pkg/util/sets"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)
type SyncContext struct {
Context context.Context
Log loghelper.Logger
PhysicalClient client.Client
VirtualClient client.Client
CurrentNamespace string
CurrentNamespaceClient client.Client
}
type RegisterContext struct {
Context context.Context
Options *controllercontext.VirtualClusterOptions
Controllers sets.Set[string]
CurrentNamespace string
CurrentNamespaceClient client.Client
VirtualManager ctrl.Manager
PhysicalManager ctrl.Manager
}
func ConvertContext(registerContext *RegisterContext, logName string) *SyncContext {
return &SyncContext{
Context: registerContext.Context,
Log: loghelper.New(logName),
PhysicalClient: registerContext.PhysicalManager.GetClient(),
VirtualClient: registerContext.VirtualManager.GetClient(),
CurrentNamespace: registerContext.CurrentNamespace,
CurrentNamespaceClient: registerContext.CurrentNamespaceClient,
}
}