-
Notifications
You must be signed in to change notification settings - Fork 0
/
identity.go
67 lines (59 loc) · 1.89 KB
/
identity.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
62
63
64
65
66
67
package identity
import (
"context"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/sirupsen/logrus"
)
type Identity struct {
driverName string
ready bool
log *logrus.Entry
}
func NewIdentity(driverName string, l *logrus.Entry) *Identity {
return &Identity{driverName: driverName, ready: true, log: l}
}
// GetPluginInfo returns metadata of the plugin.
func (i *Identity) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
return &csi.GetPluginInfoResponse{
Name: i.driverName,
}, nil
}
// GetPluginCapabilities returns available capabilities of the plugin.
func (i *Identity) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
return &csi.GetPluginCapabilitiesResponse{
Capabilities: []*csi.PluginCapability{
{
Type: &csi.PluginCapability_Service_{
Service: &csi.PluginCapability_Service{
Type: csi.PluginCapability_Service_CONTROLLER_SERVICE,
},
},
},
{
Type: &csi.PluginCapability_Service_{
Service: &csi.PluginCapability_Service{
Type: csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS,
},
},
},
{
Type: &csi.PluginCapability_VolumeExpansion_{
VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
Type: csi.PluginCapability_VolumeExpansion_OFFLINE,
},
},
},
},
}, nil
}
// Probe returns the health and readiness of the plugin.
func (i *Identity) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) {
i.log.WithField("method", "probe").Info("check whether the plugin is ready")
return &csi.ProbeResponse{
Ready: &wrappers.BoolValue{
// TODO: should we check e.g. that network is available or that all the cli tools are available ?
Value: i.ready,
},
}, nil
}