forked from moby/swarmkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.go
61 lines (47 loc) · 1.44 KB
/
plugin.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
52
53
54
55
56
57
58
59
60
61
package csi
import (
"context"
"google.golang.org/grpc"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/docker/swarmkit/api"
)
type NodePlugin interface {
NodeGetInfo(ctx context.Context) (*api.NodeCSIInfo, error)
}
// plugin represents an individual CSI node plugin
type nodePlugin struct {
// name is the name of the plugin, which is also the name used as the
// Driver.Name field
name string
// node ID is identifier for the node.
nodeID string
// socket is the unix socket to connect to this plugin at.
socket string
// cc is the grpc client connection
cc *grpc.ClientConn
// idClient is the identity service client
idClient csi.IdentityClient
// nodeClient is the node service client
nodeClient csi.NodeClient
}
// NewNodePlugin creates a new NodePlugin object.
func NewNodePlugin(nodeId string, name string) NodePlugin {
return &nodePlugin{
name: name,
nodeID: nodeId,
}
}
func (np *nodePlugin) Client() csi.NodeClient {
return np.nodeClient
}
// makeGetInfoRequest makes a csi.NodeGetInfoRequest.
// Messsage is emoty in CSI specs - https://github.com/container-storage-interface/spec/blob/v1.2.0/csi.proto#L1292-L1293
func (np *nodePlugin) makeGetInfoRequest() *csi.NodeGetInfoRequest {
return &csi.NodeGetInfoRequest{}
}
func (np *nodePlugin) NodeGetInfo(ctx context.Context) (*api.NodeCSIInfo, error) {
resp := &csi.NodeGetInfoResponse{
NodeId: np.nodeID,
}
return makeNodeInfo(resp), nil
}