Skip to content

Commit

Permalink
Enable gofumpt linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dabradley committed Oct 10, 2024
1 parent 243db26 commit c45c944
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ linters:
enable:
- revive
- gofmt
- gofumpt
- testifylint
- stylecheck
- predeclared
Expand Down
6 changes: 3 additions & 3 deletions pkg/azurelustre/fake_mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type fakeMounter struct {
}

// Mount overrides mount.FakeMounter.Mount.
func (f *fakeMounter) Mount(source string, target string, fstype string, options []string) error {
func (f *fakeMounter) Mount(source, target, fstype string, options []string) error {
if strings.Contains(source, "ut-container") {
return fmt.Errorf("fake Mount: source error")
} else if strings.Contains(target, "error_mount") {
Expand All @@ -39,7 +39,7 @@ func (f *fakeMounter) Mount(source string, target string, fstype string, options
}

// MountSensitive overrides mount.FakeMounter.MountSensitive.
func (f *fakeMounter) MountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error {
func (f *fakeMounter) MountSensitive(source, target, fstype string, options, sensitiveOptions []string) error {
if strings.Contains(source, "ut-container-sens") {
return fmt.Errorf("fake MountSensitive: source error")
} else if strings.Contains(target, "error_mount_sens") {
Expand All @@ -50,7 +50,7 @@ func (f *fakeMounter) MountSensitive(source string, target string, fstype string
}

// MountSensitiveWithoutSystemdWithMountFlags overrides mount.FakeMounter.MountSensitiveWithoutSystemdWithMountFlags.
func (f *fakeMounter) MountSensitiveWithoutSystemdWithMountFlags(source string, target string, fstype string, options []string, sensitiveOptions []string, mountFlags []string) error {
func (f *fakeMounter) MountSensitiveWithoutSystemdWithMountFlags(source, target, fstype string, options, sensitiveOptions, mountFlags []string) error {
if strings.Contains(source, "ut-container-sens-mountflags") {
return fmt.Errorf("fake MountSensitiveWithoutSystemdWithMountFlags: source error")
} else if strings.Contains(target, "error_mount_sens_mountflags") {
Expand Down
14 changes: 6 additions & 8 deletions pkg/azurelustre/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func (d *Driver) NodePublishVolume(
}

err = mountVolumeAtPath(d, source, target, mountOptions)

if err != nil {
if removeErr := os.Remove(target); removeErr != nil {
return nil, status.Errorf(
Expand Down Expand Up @@ -249,7 +248,7 @@ func getVolume(volumeID string, context map[string]string) (*lustreVolume, error
return vol, nil
}

func mountVolumeAtPath(d *Driver, source string, target string, mountOptions []string) error {
func mountVolumeAtPath(d *Driver, source, target string, mountOptions []string) error {
d.kernelModuleLock.Lock()
defer d.kernelModuleLock.Unlock()
err := d.mounter.MountSensitiveWithoutSystemdWithMountFlags(
Expand Down Expand Up @@ -529,7 +528,7 @@ func (d *Driver) ensureMountPoint(target string) (bool, error) {
return !notMnt, nil
}

func (d *Driver) createSubDir(vol *lustreVolume, mountPath string, subDirPath string, mountOptions []string) error {
func (d *Driver) createSubDir(vol *lustreVolume, mountPath, subDirPath string, mountOptions []string) error {
if err := d.internalMount(vol, mountPath, mountOptions); err != nil {
return err
}
Expand All @@ -547,7 +546,7 @@ func (d *Driver) createSubDir(vol *lustreVolume, mountPath string, subDirPath st

klog.V(2).Infof("Making subdirectory at %q", internalVolumePath)

if err := os.MkdirAll(internalVolumePath, 0775); err != nil {
if err := os.MkdirAll(internalVolumePath, 0o775); err != nil {
return status.Errorf(codes.Internal, "failed to make subdirectory: %v", err.Error())
}

Expand All @@ -558,7 +557,7 @@ func getSourceString(mgsIPAddress, azureLustreName string) string {
return fmt.Sprintf("%s@tcp:/%s", mgsIPAddress, azureLustreName)
}

func getInternalMountPath(workingMountDir string, mountPath string) (string, error) {
func getInternalMountPath(workingMountDir, mountPath string) (string, error) {
mountPath = strings.Trim(mountPath, "/")

if isSubpath := ensureStrictSubpath(mountPath); !isSubpath {
Expand All @@ -572,7 +571,7 @@ func getInternalMountPath(workingMountDir string, mountPath string) (string, err
return filepath.Join(workingMountDir, mountPath), nil
}

func getInternalVolumePath(workingMountDir string, mountPath string, subDirPath string) (string, error) {
func getInternalVolumePath(workingMountDir, mountPath, subDirPath string) (string, error) {
internalMountPath, err := getInternalMountPath(workingMountDir, mountPath)
if err != nil {
return "", err
Expand Down Expand Up @@ -629,7 +628,6 @@ func (d *Driver) internalMount(vol *lustreVolume, mountPath string, mountOptions
)

err = mountVolumeAtPath(d, source, target, mountOptions)

if err != nil {
if removeErr := os.Remove(target); removeErr != nil {
return status.Errorf(
Expand Down Expand Up @@ -701,7 +699,7 @@ func getLustreVolFromID(id string) (*lustreVolume, error) {
}

// Convert context parameters to a lustreVolume
func newLustreVolume(volumeID string, volumeName string, params map[string]string) (*lustreVolume, error) {
func newLustreVolume(volumeID, volumeName string, params map[string]string) (*lustreVolume, error) {
var mgsIPAddress, azureLustreName, subDir string
// validate parameters (case-insensitive).
for k, v := range params {
Expand Down
2 changes: 1 addition & 1 deletion pkg/azurelustre/nodeserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
}

func makeDir(pathname string) error {
err := os.MkdirAll(pathname, os.FileMode(0755))
err := os.MkdirAll(pathname, os.FileMode(0o755))
if err != nil {
if !os.IsExist(err) {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/csi-common/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type CSIDriver struct {

// Creates a NewCSIDriver object. Assumes vendor version is equal to driver version &
// does not support optional driver plugin info manifest field. Refer to CSI spec for more details.
func NewCSIDriver(name string, v string, nodeID string) *CSIDriver {
func NewCSIDriver(name, v, nodeID string) *CSIDriver {
if name == "" {
klog.Errorf("Driver name missing")
return nil
Expand Down
1 change: 1 addition & 0 deletions pkg/csi-common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func NewControllerServiceCapability(capability csi.ControllerServiceCapability_R
},
}
}

func NewNodeServiceCapability(capability csi.NodeServiceCapability_RPC_Type) *csi.NodeServiceCapability {
return &csi.NodeServiceCapability{
Type: &csi.NodeServiceCapability_Rpc{
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func GiBToBytes(volumeSizeGiB int64) int64 {
// allocates volumes in gibibyte-sized chunks,
// RoundUpSize(1500 * 1024*1024, 1024*1024*1024) returns '2'
// (2 GiB is the smallest allocatable volume that can hold 1500MiB)
func roundUpSize(volumeSizeBytes int64, allocationUnitBytes int64) int64 {
func roundUpSize(volumeSizeBytes, allocationUnitBytes int64) int64 {
roundedUp := volumeSizeBytes / allocationUnitBytes
if volumeSizeBytes%allocationUnitBytes > 0 {
roundedUp++
Expand All @@ -78,7 +78,7 @@ func GetMountOptions(options []string) string {
}

func MakeDir(pathname string) error {
err := os.MkdirAll(pathname, os.FileMode(0775)) // TODO_JUSJIN: revisit the ACL
err := os.MkdirAll(pathname, os.FileMode(0o775)) // TODO_JUSJIN: revisit the ACL
if err != nil {
if !os.IsExist(err) {
return err
Expand Down
2 changes: 1 addition & 1 deletion test/utils/azure/azure_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Client struct {
groupsClient *armresources.ResourceGroupsClient
}

func GetClient(cloud string, subscriptionID string, clientID string, tenantID string, clientSecret string) (*Client, error) {
func GetClient(cloud, subscriptionID, clientID, tenantID, clientSecret string) (*Client, error) {
env, err := azure.EnvironmentFromName(cloud)
if err != nil {
return nil, err
Expand Down

0 comments on commit c45c944

Please sign in to comment.