Skip to content

Commit

Permalink
util: add ValidateGroupControllerServiceRequest helper
Browse files Browse the repository at this point in the history
added ValidateGroupControllerServiceRequest
helper function which can be used to validate the
group controller service request.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 authored and mergify[bot] committed Feb 9, 2024
1 parent 5ecfa06 commit 2af26ca
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions internal/csi-common/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,21 @@ func (d *CSIDriver) AddGroupControllerServiceCapabilities(cl []csi.GroupControll

d.groupCapabilities = csc
}

// ValidateGroupControllerServiceRequest validates the group controller
// plugin capabilities.
//
//nolint:interfacer // c can be of type fmt.Stringer, but that does not make the API clearer
func (d *CSIDriver) ValidateGroupControllerServiceRequest(c csi.GroupControllerServiceCapability_RPC_Type) error {
if c == csi.GroupControllerServiceCapability_RPC_UNKNOWN {
return nil
}

for _, capability := range d.groupCapabilities {
if c == capability.GetRpc().GetType() {
return nil
}
}

return status.Error(codes.InvalidArgument, c.String())
}

0 comments on commit 2af26ca

Please sign in to comment.