Skip to content

Commit

Permalink
Complete CSI IdentityServer interface (caoyingjunz#7)
Browse files Browse the repository at this point in the history
- GetPluginInfo
- Probe
- GetPluginCapabilities
  • Loading branch information
caoyingjunz authored Apr 8, 2023
1 parent 0db08cd commit 93c0147
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cmd/localstorageplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func main() {
flag.Parse()

cfg := localstorage.Config{
DriverName: *driverName,
Endpoint: *endpoint,
Version: version,
DriverName: *driverName,
Endpoint: *endpoint,
VendorVersion: version,
}

driver, err := localstorage.NewLocalStorage(cfg)
Expand Down
18 changes: 15 additions & 3 deletions pkg/localstorage/identityserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package localstorage

import (
"context"

"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/protobuf/ptypes/wrappers"
)
Expand All @@ -28,13 +27,26 @@ type IdentityServer struct {
}

func (ls *localStorage) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
return &csi.GetPluginInfoResponse{}, nil
return &csi.GetPluginInfoResponse{
Name: ls.config.DriverName,
VendorVersion: ls.config.VendorVersion,
}, nil
}

func (ls *localStorage) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) {
return &csi.ProbeResponse{Ready: &wrappers.BoolValue{Value: true}}, nil
}

func (ls *localStorage) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
return &csi.GetPluginCapabilitiesResponse{}, nil
return &csi.GetPluginCapabilitiesResponse{
Capabilities: []*csi.PluginCapability{
{
Type: &csi.PluginCapability_Service_{
Service: &csi.PluginCapability_Service{
Type: csi.PluginCapability_Service_CONTROLLER_SERVICE,
},
},
},
},
}, nil
}
8 changes: 4 additions & 4 deletions pkg/localstorage/localstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ type localStorage struct {
}

type Config struct {
DriverName string
Endpoint string
Version string
DriverName string
Endpoint string
VendorVersion string
}

func NewLocalStorage(cfg Config) (*localStorage, error) {
klog.V(2).Infof("Driver: %v version: %v", cfg.DriverName, cfg.Version)
klog.V(2).Infof("Driver: %v version: %v", cfg.DriverName, cfg.VendorVersion)

ls := &localStorage{
config: cfg,
Expand Down

0 comments on commit 93c0147

Please sign in to comment.