github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/cloud/pkg/csidriver/identityserver.go (about) 1 /* 2 Copyright 2019 The KubeEdge Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package csidriver 18 19 import ( 20 "github.com/container-storage-interface/spec/lib/go/csi" 21 "golang.org/x/net/context" 22 "google.golang.org/grpc/codes" 23 "google.golang.org/grpc/status" 24 "k8s.io/klog" 25 ) 26 27 type identityServer struct { 28 name string 29 version string 30 } 31 32 // newIdentityServer creates identity server 33 func newIdentityServer(name, version string) *identityServer { 34 return &identityServer{ 35 name: name, 36 version: version, 37 } 38 } 39 40 func (ids *identityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) { 41 klog.V(4).Info("using default GetPluginInfo") 42 43 if ids.name == "" { 44 return nil, status.Error(codes.Unavailable, "driver name not configured") 45 } 46 47 if ids.version == "" { 48 return nil, status.Error(codes.Unavailable, "driver is missing version") 49 } 50 51 return &csi.GetPluginInfoResponse{ 52 Name: ids.name, 53 VendorVersion: ids.version, 54 }, nil 55 } 56 57 func (ids *identityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) { 58 return &csi.ProbeResponse{}, nil 59 } 60 61 func (ids *identityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { 62 klog.V(4).Info("using default capabilities") 63 return &csi.GetPluginCapabilitiesResponse{ 64 Capabilities: []*csi.PluginCapability{ 65 { 66 Type: &csi.PluginCapability_Service_{ 67 Service: &csi.PluginCapability_Service{ 68 Type: csi.PluginCapability_Service_CONTROLLER_SERVICE, 69 }, 70 }, 71 }, 72 }, 73 }, nil 74 }