simplify returning boolean expression in /pkg/volume

Signed-off-by: 刁浩 10284789 <diao.hao@zte.com.cn>
This commit is contained in:
刁浩 10284789 2021-05-25 02:39:55 +00:00
parent f545438bd3
commit 5908cd0d90
5 changed files with 5 additions and 21 deletions

View File

@ -628,10 +628,7 @@ func getAttachmentName(volName, csiDriverName, nodeName string) string {
// and false otherwise // and false otherwise
func isAttachmentName(unknownString string) bool { func isAttachmentName(unknownString string) bool {
// 68 == "csi-" + len(sha256hash) // 68 == "csi-" + len(sha256hash)
if strings.HasPrefix(unknownString, "csi-") && len(unknownString) == 68 { return strings.HasPrefix(unknownString, "csi-") && len(unknownString) == 68
return true
}
return false
} }
func makeDeviceMountPath(plugin *csiPlugin, spec *volume.Spec) (string, error) { func makeDeviceMountPath(plugin *csiPlugin, spec *volume.Spec) (string, error) {

View File

@ -143,8 +143,5 @@ func inUseError(err error) bool {
// if this is a failed precondition error then that means driver does not support expansion // if this is a failed precondition error then that means driver does not support expansion
// of in-use volumes // of in-use volumes
// More info - https://github.com/container-storage-interface/spec/blob/master/spec.md#controllerexpandvolume-errors // More info - https://github.com/container-storage-interface/spec/blob/master/spec.md#controllerexpandvolume-errors
if st.Code() == codes.FailedPrecondition { return st.Code() == codes.FailedPrecondition
return true
}
return false
} }

View File

@ -88,10 +88,7 @@ func (plugin *emptyDirPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
} }
func (plugin *emptyDirPlugin) CanSupport(spec *volume.Spec) bool { func (plugin *emptyDirPlugin) CanSupport(spec *volume.Spec) bool {
if spec.Volume != nil && spec.Volume.EmptyDir != nil { return spec.Volume != nil && spec.Volume.EmptyDir != nil
return true
}
return false
} }
func (plugin *emptyDirPlugin) RequiresRemount(spec *volume.Spec) bool { func (plugin *emptyDirPlugin) RequiresRemount(spec *volume.Spec) bool {

View File

@ -249,11 +249,7 @@ func defaultCapabilities() *DriverCapabilities {
// isCmdNotSupportedErr checks if the error corresponds to command not supported by // isCmdNotSupportedErr checks if the error corresponds to command not supported by
// driver. // driver.
func isCmdNotSupportedErr(err error) bool { func isCmdNotSupportedErr(err error) bool {
if err != nil && err.Error() == StatusNotSupported { return err != nil && err.Error() == StatusNotSupported
return true
}
return false
} }
// handleCmdResponse processes the command output and returns the appropriate // handleCmdResponse processes the command output and returns the appropriate

View File

@ -148,10 +148,7 @@ func IsOperationFinishedError(err error) bool {
// on PVC and actual filesystem on disk did not match // on PVC and actual filesystem on disk did not match
func IsFilesystemMismatchError(err error) bool { func IsFilesystemMismatchError(err error) bool {
mountError := mount.MountError{} mountError := mount.MountError{}
if errors.As(err, &mountError) && mountError.Type == mount.FilesystemMismatch { return errors.As(err, &mountError) && mountError.Type == mount.FilesystemMismatch
return true
}
return false
} }
// IsUncertainProgressError checks if given error is of type that indicates // IsUncertainProgressError checks if given error is of type that indicates