mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
simplify returning boolean expression in /pkg/volume
Signed-off-by: 刁浩 10284789 <diao.hao@zte.com.cn>
This commit is contained in:
parent
f545438bd3
commit
5908cd0d90
@ -628,10 +628,7 @@ func getAttachmentName(volName, csiDriverName, nodeName string) string {
|
||||
// and false otherwise
|
||||
func isAttachmentName(unknownString string) bool {
|
||||
// 68 == "csi-" + len(sha256hash)
|
||||
if strings.HasPrefix(unknownString, "csi-") && len(unknownString) == 68 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return strings.HasPrefix(unknownString, "csi-") && len(unknownString) == 68
|
||||
}
|
||||
|
||||
func makeDeviceMountPath(plugin *csiPlugin, spec *volume.Spec) (string, error) {
|
||||
|
@ -143,8 +143,5 @@ func inUseError(err error) bool {
|
||||
// if this is a failed precondition error then that means driver does not support expansion
|
||||
// of in-use volumes
|
||||
// More info - https://github.com/container-storage-interface/spec/blob/master/spec.md#controllerexpandvolume-errors
|
||||
if st.Code() == codes.FailedPrecondition {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return st.Code() == codes.FailedPrecondition
|
||||
}
|
||||
|
@ -88,10 +88,7 @@ func (plugin *emptyDirPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||
}
|
||||
|
||||
func (plugin *emptyDirPlugin) CanSupport(spec *volume.Spec) bool {
|
||||
if spec.Volume != nil && spec.Volume.EmptyDir != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return spec.Volume != nil && spec.Volume.EmptyDir != nil
|
||||
}
|
||||
|
||||
func (plugin *emptyDirPlugin) RequiresRemount(spec *volume.Spec) bool {
|
||||
|
@ -249,11 +249,7 @@ func defaultCapabilities() *DriverCapabilities {
|
||||
// isCmdNotSupportedErr checks if the error corresponds to command not supported by
|
||||
// driver.
|
||||
func isCmdNotSupportedErr(err error) bool {
|
||||
if err != nil && err.Error() == StatusNotSupported {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return err != nil && err.Error() == StatusNotSupported
|
||||
}
|
||||
|
||||
// handleCmdResponse processes the command output and returns the appropriate
|
||||
|
@ -148,10 +148,7 @@ func IsOperationFinishedError(err error) bool {
|
||||
// on PVC and actual filesystem on disk did not match
|
||||
func IsFilesystemMismatchError(err error) bool {
|
||||
mountError := mount.MountError{}
|
||||
if errors.As(err, &mountError) && mountError.Type == mount.FilesystemMismatch {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return errors.As(err, &mountError) && mountError.Type == mount.FilesystemMismatch
|
||||
}
|
||||
|
||||
// IsUncertainProgressError checks if given error is of type that indicates
|
||||
|
Loading…
Reference in New Issue
Block a user