Skip to content

Commit

Permalink
feat: add hook options
Browse files Browse the repository at this point in the history
Signed-off-by: hlts2 <[email protected]>
  • Loading branch information
hlts2 committed Dec 24, 2024
1 parent d116157 commit 9c521a4
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pkg/driver/hooks/options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package hooks

import (
"os"

"k8s.io/client-go/kubernetes"
)

type Option func(*hook)

var defaultOpts = []Option{
WithNodeName(os.Getenv("KUBE_NODE_NAME")),
}

// WithKubernetesClient returns Option to set Kubernetes API client.
func WithKubernetesClient(client kubernetes.Interface) Option {
return func(h *hook) {
if client != nil {
h.client = client
}
}
}

func WithKubernetesClientConfigPath(path string) Option {
return func(h *hook) {
if path != "" {
h.clientCfgPath = path
}
}
}

// WithNodeName returns Option to set node node name.
func WithNodeName(name string) Option {
return func(h *hook) {
if name != "" {
h.nodeName = name
}
}
}

0 comments on commit 9c521a4

Please sign in to comment.