/
option.go
51 lines (42 loc) · 968 Bytes
/
option.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
package k8s
import (
"context"
"github.com/go-logr/logr"
"github.com/ovh/configstore"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)
type CtrlOptions struct {
CTX context.Context
Client client.Client
Log logr.Logger
DClient *DynamicClientWrapper
Scheme *runtime.Scheme
ConfigStore *configstore.Store
}
type Option func(ops *CtrlOptions)
func WithClient(client client.Client) Option {
return func(ops *CtrlOptions) {
ops.Client = client
}
}
func WithDClient(dClient *DynamicClientWrapper) Option {
return func(ops *CtrlOptions) {
ops.DClient = dClient
}
}
func WithScheme(scheme *runtime.Scheme) Option {
return func(ops *CtrlOptions) {
ops.Scheme = scheme
}
}
func WithLog(log logr.Logger) Option {
return func(ops *CtrlOptions) {
ops.Log = log
}
}
func WithConfigStore(store *configstore.Store) Option {
return func(ops *CtrlOptions) {
ops.ConfigStore = store
}
}