diff --git a/cmd/mock-driver/main.go b/cmd/mock-driver/main.go index c7800c7d..fdf46a61 100644 --- a/cmd/mock-driver/main.go +++ b/cmd/mock-driver/main.go @@ -34,6 +34,7 @@ func main() { flag.StringVar(&config.DriverName, "name", service.Name, "CSI driver name.") flag.Int64Var(&config.AttachLimit, "attach-limit", 0, "number of attachable volumes on a node") flag.BoolVar(&config.NodeExpansionRequired, "node-expand-required", false, "Enables NodeServiceCapability_RPC_EXPAND_VOLUME capacity.") + flag.BoolVar(&config.DisableControllerExpansion, "disable-controller-expansion", false, "Disables ControllerServiceCapability_RPC_EXPAND_VOLUME capability.") flag.Parse() endpoint := os.Getenv("CSI_ENDPOINT") diff --git a/mock/service/controller.go b/mock/service/controller.go index 584154e5..50855dbd 100644 --- a/mock/service/controller.go +++ b/mock/service/controller.go @@ -386,20 +386,23 @@ func (s *service) ControllerGetCapabilities( }, }, }, - { + } + + if !s.config.DisableAttach { + caps = append(caps, &csi.ControllerServiceCapability{ Type: &csi.ControllerServiceCapability_Rpc{ Rpc: &csi.ControllerServiceCapability_RPC{ - Type: csi.ControllerServiceCapability_RPC_EXPAND_VOLUME, + Type: csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME, }, }, - }, + }) } - if !s.config.DisableAttach { + if !s.config.DisableControllerExpansion { caps = append(caps, &csi.ControllerServiceCapability{ Type: &csi.ControllerServiceCapability_Rpc{ Rpc: &csi.ControllerServiceCapability_RPC{ - Type: csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME, + Type: csi.ControllerServiceCapability_RPC_EXPAND_VOLUME, }, }, }) diff --git a/mock/service/service.go b/mock/service/service.go index 31d85ee5..a6f85a02 100644 --- a/mock/service/service.go +++ b/mock/service/service.go @@ -27,10 +27,11 @@ var Manifest = map[string]string{ } type Config struct { - DisableAttach bool - DriverName string - AttachLimit int64 - NodeExpansionRequired bool + DisableAttach bool + DriverName string + AttachLimit int64 + NodeExpansionRequired bool + DisableControllerExpansion bool } // Service is the CSI Mock service provider.