diff --git a/.cirrus.yml b/.cirrus.yml index 2bb7e7abeb..1e566a7fce 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -338,7 +338,7 @@ osx_alt_build_task: # The previous task may have been canceled or aborted. prep_script: &mac_cleanup "contrib/cirrus/mac_cleanup.sh" lint_script: - - make lint || true # TODO: Enable when code passes check + - make golangci-lint basic_build_script: - make .install.ginkgo - make podman-remote diff --git a/cmd/podman-mac-helper/install.go b/cmd/podman-mac-helper/install.go index 4aec4d95ac..ff6d4d7072 100644 --- a/cmd/podman-mac-helper/install.go +++ b/cmd/podman-mac-helper/install.go @@ -18,8 +18,8 @@ import ( ) const ( - rwx_rx_rx = 0755 - rw_r_r = 0644 + mode755 = 0755 + mode644 = 0644 ) const launchConfig = ` @@ -109,7 +109,7 @@ func install(cmd *cobra.Command, args []string) error { return err } - file, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_EXCL, rw_r_r) + file, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_EXCL, mode644) if err != nil { return fmt.Errorf("creating helper plist file: %w", err) } @@ -138,7 +138,7 @@ func restrictRecursive(targetDir string, until string) error { if err = os.Chown(targetDir, 0, 0); err != nil { return fmt.Errorf("could not update ownership of helper path: %w", err) } - if err = os.Chmod(targetDir, rwx_rx_rx|fs.ModeSticky); err != nil { + if err = os.Chmod(targetDir, mode755|fs.ModeSticky); err != nil { return fmt.Errorf("could not update permissions of helper path: %w", err) } targetDir = filepath.Dir(targetDir) @@ -205,7 +205,7 @@ func installExecutable(user string) (string, error) { } targetDir := filepath.Join(installPrefix, "podman", "helper", user) - if err := os.MkdirAll(targetDir, rwx_rx_rx); err != nil { + if err := os.MkdirAll(targetDir, mode755); err != nil { return "", fmt.Errorf("could not create helper directory structure: %w", err) } @@ -220,7 +220,7 @@ func installExecutable(user string) (string, error) { } install := filepath.Join(targetDir, filepath.Base(exec)) - return install, copyFile(install, exec, rwx_rx_rx) + return install, copyFile(install, exec, mode755) } func copyFile(dest string, source string, perms fs.FileMode) error { diff --git a/cmd/podman-mac-helper/main.go b/cmd/podman-mac-helper/main.go index 55aaa0e7c0..41b960e45a 100644 --- a/cmd/podman-mac-helper/main.go +++ b/cmd/podman-mac-helper/main.go @@ -72,7 +72,7 @@ func getUserInfo(name string) (string, string, string, error) { entry := readCapped(output) elements := strings.Split(entry, ":") if len(elements) < 9 || elements[0] != name { - return "", "", "", errors.New("Could not look up user") + return "", "", "", errors.New("could not look up user") } return elements[0], elements[2], elements[8], nil diff --git a/cmd/podman-mac-helper/uninstall.go b/cmd/podman-mac-helper/uninstall.go index 3896394cec..1537e2ba82 100644 --- a/cmd/podman-mac-helper/uninstall.go +++ b/cmd/podman-mac-helper/uninstall.go @@ -3,12 +3,12 @@ package main import ( + "errors" "fmt" + "io/fs" "os" "os/exec" "path/filepath" - "io/fs" - "errors" "github.com/spf13/cobra" ) @@ -67,7 +67,7 @@ func uninstall(cmd *cobra.Command, args []string) error { return fmt.Errorf("could not stat dockerSock: %v", err) } if target, err := os.Readlink(dockerSock); err != nil { - //Return an error if unable to read the symlink + // Return an error if unable to read the symlink return fmt.Errorf("could not read dockerSock symlink: %v", err) } else { // Check if the target of the symlink matches the expected target diff --git a/pkg/machine/applehv/machine.go b/pkg/machine/applehv/machine.go index d57ceb9292..c5b397b3b0 100644 --- a/pkg/machine/applehv/machine.go +++ b/pkg/machine/applehv/machine.go @@ -107,7 +107,7 @@ func generateSystemDFilesForVirtiofsMounts(mounts []machine.VirtIoFs) []ignition // for automatic mounting on boot, and a "preparatory" service file that disables FCOS security, performs // the mkdir of the mount point, and then re-enables security. This must be done for each mount. - var unitFiles []ignition.Unit + unitFiles := make([]ignition.Unit, 0, len(mounts)) for _, mnt := range mounts { // Here we are looping the mounts and for each mount, we are adding two unit files // for virtiofs. One unit file is the mount itself and the second is to automount it diff --git a/pkg/machine/applehv/stubber.go b/pkg/machine/applehv/stubber.go index 72dd51424c..0603485a95 100644 --- a/pkg/machine/applehv/stubber.go +++ b/pkg/machine/applehv/stubber.go @@ -63,7 +63,7 @@ func (a AppleHVStubber) CreateVM(opts define.CreateVMOpts, mc *vmconfigs.Machine } mc.AppleHypervisor.Vfkit.Endpoint = localhostURI + ":" + strconv.Itoa(randPort) - var virtiofsMounts []machine.VirtIoFs + virtiofsMounts := make([]machine.VirtIoFs, 0, len(mc.Mounts)) for _, mnt := range mc.Mounts { virtiofsMounts = append(virtiofsMounts, machine.MountToVirtIOFs(mnt)) } diff --git a/pkg/machine/applehv/vfkit.go b/pkg/machine/applehv/vfkit.go index e476614890..0a20d52f74 100644 --- a/pkg/machine/applehv/vfkit.go +++ b/pkg/machine/applehv/vfkit.go @@ -64,7 +64,7 @@ func getIgnitionVsockDevice(path string) (vfConfig.VirtioDevice, error) { } func virtIOFsToVFKitVirtIODevice(mounts []*vmconfigs.Mount) ([]vfConfig.VirtioDevice, error) { - var virtioDevices []vfConfig.VirtioDevice + virtioDevices := make([]vfConfig.VirtioDevice, 0, len(mounts)) for _, vol := range mounts { virtfsDevice, err := vfConfig.VirtioFsNew(vol.Source, vol.Tag) if err != nil { diff --git a/pkg/machine/applehv/vfkit/config.go b/pkg/machine/applehv/vfkit/config.go index 816f63167b..953489970d 100644 --- a/pkg/machine/applehv/vfkit/config.go +++ b/pkg/machine/applehv/vfkit/config.go @@ -83,7 +83,8 @@ func (vf *VfkitHelper) stateChange(newState rest.StateChange) error { return err } payload := bytes.NewReader(b) - _, err = vf.post(vf.Endpoint+state, payload) + serverResponse, err := vf.post(vf.Endpoint+state, payload) + _ = serverResponse.Body.Close() return err }