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 <[email protected]>
  • Loading branch information
Madhu-1 committed Feb 5, 2024
1 parent 26484e5 commit a86be45
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 a86be45

Please sign in to comment.