@@ -6,50 +6,68 @@ import (
66
77 "github.com/hashicorp/go-hclog"
88 "github.com/hashicorp/go-plugin"
9- proto "github.com/slyngdk/node-drain/api/plugins/proto/v1"
9+ pluginv1 "github.com/slyngdk/node-drain/api/plugins/proto/v1"
10+ "google.golang.org/protobuf/proto"
1011)
1112
12- var _ proto .DrainServiceServer = DrainServer {}
13+ var _ pluginv1 .DrainServiceServer = DrainServer {}
1314
1415type DrainServer struct {
1516 Logger hclog.Logger
1617 Impl DrainPlugin
1718}
1819
19- func (s DrainServer ) Init (ctx context.Context , request * proto.InitRequest ) (* proto.InitResponse , error ) {
20- info , err := s .Impl .Init (ctx , s .Logger , DrainPluginSettings {})
20+ func (s DrainServer ) PluginInfo (ctx context.Context , _ * pluginv1.PluginInfoRequest ) (* pluginv1.PluginInfoResponse , error ) {
21+ info , err := s .Impl .PluginInfo (ctx )
22+ if err != nil {
23+ return nil , err
24+ }
25+ return pluginv1.PluginInfoResponse_builder {
26+ Id : proto .String (info .ID ),
27+ ConfigFormat : & info .ConfigFormat ,
28+ }.Build (), nil
29+ }
30+
31+ func (s DrainServer ) Init (ctx context.Context , request * pluginv1.InitRequest ) (* pluginv1.InitResponse , error ) {
32+ err := s .Impl .Init (ctx , s .Logger , DrainPluginSettings {
33+ Config : request .GetConfig (),
34+ })
2135 if err != nil {
2236 return nil , err
2337 }
2438
25- return & proto.InitResponse {
26- Id : info .ID ,
27- }, nil
39+ return & pluginv1.InitResponse {}, nil
2840}
2941
30- func (s DrainServer ) IsSupported (ctx context.Context , request * proto .IsSupportedRequest ) (* proto .IsSupportedResponse , error ) {
42+ func (s DrainServer ) IsSupported (ctx context.Context , _ * pluginv1 .IsSupportedRequest ) (* pluginv1 .IsSupportedResponse , error ) {
3143 supported , err := s .Impl .IsSupported (ctx )
32- return & proto.IsSupportedResponse {Supported : supported }, err
44+ return pluginv1.IsSupportedResponse_builder {
45+ Supported : proto .Bool (supported ),
46+ }.Build (), err
3347}
3448
35- func (s DrainServer ) IsHealthy (ctx context.Context , request * proto .IsHealthyRequest ) (* proto .IsHealthyResponse , error ) {
49+ func (s DrainServer ) IsHealthy (ctx context.Context , _ * pluginv1 .IsHealthyRequest ) (* pluginv1 .IsHealthyResponse , error ) {
3650 healthy , err := s .Impl .IsHealthy (ctx )
37- return & proto.IsHealthyResponse {Healthy : healthy }, err
51+ return pluginv1.IsHealthyResponse_builder {
52+ Healthy : proto .Bool (healthy ),
53+ }.Build (), err
3854}
3955
40- func (s DrainServer ) IsDrainOk (ctx context.Context , request * proto.IsDrainOkRequest ) (* proto.IsDrainOkResponse , error ) {
41- ok , err := s .Impl .IsDrainOk (ctx , request .NodeName )
42- return & proto.IsDrainOkResponse {Ok : ok }, err
56+ func (s DrainServer ) IsDrainOk (ctx context.Context , request * pluginv1.IsDrainOkRequest ) (* pluginv1.IsDrainOkResponse , error ) {
57+ ok , err := s .Impl .IsDrainOk (ctx , request .GetNodeName ())
58+ return pluginv1.IsDrainOkResponse_builder {
59+ Ok : proto .Bool (ok ),
60+ }.Build (), err
4361}
4462
45- func (s DrainServer ) PreDrain (ctx context.Context , request * proto .PreDrainRequest ) (* proto .PreDrainResponse , error ) {
46- err := s .Impl .PreDrain (ctx , request .NodeName )
47- return & proto .PreDrainResponse {}, err
63+ func (s DrainServer ) PreDrain (ctx context.Context , request * pluginv1 .PreDrainRequest ) (* pluginv1 .PreDrainResponse , error ) {
64+ err := s .Impl .PreDrain (ctx , request .GetNodeName () )
65+ return & pluginv1 .PreDrainResponse {}, err
4866}
4967
50- func (s DrainServer ) PostDrain (ctx context.Context , request * proto .PostDrainRequest ) (* proto .PostDrainResponse , error ) {
51- err := s .Impl .PostDrain (ctx , request .NodeName )
52- return & proto .PostDrainResponse {}, err
68+ func (s DrainServer ) PostDrain (ctx context.Context , request * pluginv1 .PostDrainRequest ) (* pluginv1 .PostDrainResponse , error ) {
69+ err := s .Impl .PostDrain (ctx , request .GetNodeName () )
70+ return & pluginv1 .PostDrainResponse {}, err
5371}
5472
5573func Serve (impl DrainPlugin ) {
0 commit comments