k8s.io/kubernetes@v1.29.3/test/e2e/storage/drivers/csi-test/mock/service/identity.go (about)

     1  /*
     2  Copyright 2021 The Kubernetes 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 service
    18  
    19  import (
    20  	"golang.org/x/net/context"
    21  
    22  	"github.com/container-storage-interface/spec/lib/go/csi"
    23  	"github.com/golang/protobuf/ptypes/wrappers"
    24  )
    25  
    26  func (s *service) GetPluginInfo(
    27  	ctx context.Context,
    28  	req *csi.GetPluginInfoRequest) (
    29  	*csi.GetPluginInfoResponse, error) {
    30  
    31  	return &csi.GetPluginInfoResponse{
    32  		Name:          s.config.DriverName,
    33  		VendorVersion: VendorVersion,
    34  		Manifest:      Manifest,
    35  	}, nil
    36  }
    37  
    38  func (s *service) Probe(
    39  	ctx context.Context,
    40  	req *csi.ProbeRequest) (
    41  	*csi.ProbeResponse, error) {
    42  
    43  	return &csi.ProbeResponse{
    44  		Ready: &wrappers.BoolValue{Value: true},
    45  	}, nil
    46  }
    47  
    48  func (s *service) GetPluginCapabilities(
    49  	ctx context.Context,
    50  	req *csi.GetPluginCapabilitiesRequest) (
    51  	*csi.GetPluginCapabilitiesResponse, error) {
    52  
    53  	volExpType := csi.PluginCapability_VolumeExpansion_ONLINE
    54  
    55  	if s.config.DisableOnlineExpansion {
    56  		volExpType = csi.PluginCapability_VolumeExpansion_OFFLINE
    57  	}
    58  
    59  	capabilities := []*csi.PluginCapability{
    60  		{
    61  			Type: &csi.PluginCapability_Service_{
    62  				Service: &csi.PluginCapability_Service{
    63  					Type: csi.PluginCapability_Service_CONTROLLER_SERVICE,
    64  				},
    65  			},
    66  		},
    67  		{
    68  			Type: &csi.PluginCapability_VolumeExpansion_{
    69  				VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
    70  					Type: volExpType,
    71  				},
    72  			},
    73  		},
    74  	}
    75  
    76  	if s.config.EnableTopology {
    77  		capabilities = append(capabilities,
    78  			&csi.PluginCapability{
    79  				Type: &csi.PluginCapability_Service_{
    80  					Service: &csi.PluginCapability_Service{
    81  						Type: csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS,
    82  					},
    83  				},
    84  			})
    85  	}
    86  
    87  	return &csi.GetPluginCapabilitiesResponse{
    88  		Capabilities: capabilities,
    89  	}, nil
    90  }