-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample-plugin.go
More file actions
58 lines (47 loc) · 1.34 KB
/
example-plugin.go
File metadata and controls
58 lines (47 loc) · 1.34 KB
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
package main
import (
"context"
"github.com/hashicorp/go-hclog"
"github.com/slyngdk/node-drain/api/plugins"
pluginv1 "github.com/slyngdk/node-drain/api/plugins/proto/v1"
)
type ExampleDrainPlugin struct {
logger hclog.Logger
}
func (e *ExampleDrainPlugin) PluginInfo(_ context.Context) (plugins.DrainPluginInfo, error) {
return plugins.DrainPluginInfo{
ID: "example-plugin",
ConfigFormat: pluginv1.ConfigFormat_CONFIG_FORMAT_YAML,
}, nil
}
func (e *ExampleDrainPlugin) Init(
ctx context.Context,
logger hclog.Logger,
settings plugins.DrainPluginSettings) error {
e.logger = logger
e.logger.Debug("Init()")
return nil
}
func (e *ExampleDrainPlugin) IsSupported(ctx context.Context) (bool, error) {
e.logger.Debug("IsSupported()")
return true, nil
}
func (e *ExampleDrainPlugin) IsHealthy(ctx context.Context) (bool, error) {
e.logger.Debug("IsHealthy()")
return true, nil
}
func (e *ExampleDrainPlugin) IsDrainOk(ctx context.Context, nodeName string) (bool, error) {
e.logger.Debug("IsDrainOk()")
return true, nil
}
func (e *ExampleDrainPlugin) PreDrain(ctx context.Context, nodeName string) error {
e.logger.Debug("PreDrain()")
return nil
}
func (e *ExampleDrainPlugin) PostDrain(ctx context.Context, nodeName string) error {
e.logger.Debug("PostDrain()")
return nil
}
func main() {
plugins.Serve(&ExampleDrainPlugin{})
}