Skip to content

Commit 9c521a4

Browse files
committed
feat: add hook options
Signed-off-by: hlts2 <hiroto.funakoshi.hiroto@gmail.com>
1 parent d116157 commit 9c521a4

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

pkg/driver/hooks/options.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package hooks
2+
3+
import (
4+
"os"
5+
6+
"k8s.io/client-go/kubernetes"
7+
)
8+
9+
type Option func(*hook)
10+
11+
var defaultOpts = []Option{
12+
WithNodeName(os.Getenv("KUBE_NODE_NAME")),
13+
}
14+
15+
// WithKubernetesClient returns Option to set Kubernetes API client.
16+
func WithKubernetesClient(client kubernetes.Interface) Option {
17+
return func(h *hook) {
18+
if client != nil {
19+
h.client = client
20+
}
21+
}
22+
}
23+
24+
func WithKubernetesClientConfigPath(path string) Option {
25+
return func(h *hook) {
26+
if path != "" {
27+
h.clientCfgPath = path
28+
}
29+
}
30+
}
31+
32+
// WithNodeName returns Option to set node node name.
33+
func WithNodeName(name string) Option {
34+
return func(h *hook) {
35+
if name != "" {
36+
h.nodeName = name
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)