Update linter for golang v1.25 compatibility
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
committed by
Christian Goll
parent
019408d076
commit
081d2ec61e
@@ -246,7 +246,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
}
|
||||
}
|
||||
}()
|
||||
var finishedInitialSync bool = false
|
||||
finishedInitialSync := false
|
||||
ipaddr := os.Getenv("WW_IPADDR")
|
||||
if ipaddr == "" {
|
||||
if conf.Ipaddr6 != "" {
|
||||
@@ -361,7 +361,11 @@ func updateSystem(target string, ipaddr string, port int, wwid string, tag strin
|
||||
wwlog.Error("failed to create temp directory: %s", err)
|
||||
return nil
|
||||
}
|
||||
defer os.RemoveAll(tempDir)
|
||||
defer func() {
|
||||
if err := os.RemoveAll(tempDir); err != nil {
|
||||
wwlog.Warn("failed to remove temp directory %s: %s", tempDir, err)
|
||||
}
|
||||
}()
|
||||
wwlog.Debug("unpacking runtime overlay to %s", tempDir)
|
||||
command := exec.Command("/bin/sh", "-c", fmt.Sprintf("gzip -dc | cpio -imu --directory=%s", tempDir))
|
||||
command.Stdin = resp.Body
|
||||
@@ -469,7 +473,7 @@ func atomicApplyOverlay(srcDir, destDir string) error {
|
||||
wwlog.Debug("moving symlink %s to %s", tempPath, destPath)
|
||||
err = os.Rename(tempPath, destPath)
|
||||
if err != nil {
|
||||
os.Remove(tempPath)
|
||||
_ = os.Remove(tempPath)
|
||||
return fmt.Errorf("failed to atomically move symlink %s to %s: %w", tempPath, destPath, err)
|
||||
}
|
||||
|
||||
@@ -508,7 +512,7 @@ func atomicApplyOverlay(srcDir, destDir string) error {
|
||||
wwlog.Debug("copying file from %s to temp location %s", srcPath, tempPath)
|
||||
err = copyFile(srcPath, tempPath, info)
|
||||
if err != nil {
|
||||
os.Remove(tempPath)
|
||||
_ = os.Remove(tempPath)
|
||||
return fmt.Errorf("failed to copy %s to temp location: %w", srcPath, err)
|
||||
}
|
||||
|
||||
@@ -523,7 +527,7 @@ func atomicApplyOverlay(srcDir, destDir string) error {
|
||||
wwlog.Debug("moving %s to %s", tempPath, destPath)
|
||||
err = os.Rename(tempPath, destPath)
|
||||
if err != nil {
|
||||
os.Remove(tempPath)
|
||||
_ = os.Remove(tempPath)
|
||||
return fmt.Errorf("failed to atomically move %s to %s: %w", tempPath, destPath, err)
|
||||
}
|
||||
}
|
||||
@@ -532,18 +536,22 @@ func atomicApplyOverlay(srcDir, destDir string) error {
|
||||
})
|
||||
}
|
||||
|
||||
func copyFile(src, dst string, srcInfo os.FileInfo) error {
|
||||
func copyFile(src, dst string, srcInfo os.FileInfo) (err error) {
|
||||
srcFile, err := os.Open(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer srcFile.Close()
|
||||
defer func() { _ = srcFile.Close() }()
|
||||
|
||||
dstFile, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, srcInfo.Mode())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer dstFile.Close()
|
||||
defer func() {
|
||||
if cerr := dstFile.Close(); cerr != nil && err == nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
|
||||
_, err = io.Copy(dstFile, srcFile)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user