Skip to content

Commit dcb1b3f

Browse files
author
Kaan Yalti
committed
enhancement(5235): wrap errors in step_unpack
1 parent 9666178 commit dcb1b3f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/pkg/agent/application/upgrade/step_unpack.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,15 @@ func untar(log *logger.Logger, archivePath, dataDir string, flavor string) (Unpa
425425
// Using common.MkdirAll instead of os.MkdirAll so that we can
426426
// mock it in tests.
427427
if err = common.MkdirAll(filepath.Dir(abs), 0750); err != nil {
428-
return UnpackResult{}, errors.New(err, "TarInstaller: creating directory for file "+abs, errors.TypeFilesystem, errors.M(errors.MetaKeyPath, abs))
428+
return UnpackResult{}, goerrors.Join(err, errors.New("TarInstaller: creating directory for file "+abs, errors.TypeFilesystem, errors.M(errors.MetaKeyPath, abs)))
429429
}
430430

431431
// remove any world permissions from the file
432432
// Using common.OpenFile instead of os.OpenFile so that we can
433433
// mock it in tests.
434434
wf, err := common.OpenFile(abs, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode.Perm()&0770)
435435
if err != nil {
436-
return UnpackResult{}, errors.New(err, "TarInstaller: creating file "+abs, errors.TypeFilesystem, errors.M(errors.MetaKeyPath, abs))
436+
return UnpackResult{}, goerrors.Join(err, errors.New("TarInstaller: creating file "+abs, errors.TypeFilesystem, errors.M(errors.MetaKeyPath, abs)))
437437
}
438438

439439
// Using common.Copy instead of io.Copy so that we can
@@ -456,15 +456,15 @@ func untar(log *logger.Logger, archivePath, dataDir string, flavor string) (Unpa
456456
// Using common.MkdirAll instead of os.MkdirAll so that we can
457457
// mock it in tests.
458458
if err := common.MkdirAll(abs, mode.Perm()&0770); err != nil {
459-
return UnpackResult{}, errors.New(err, "TarInstaller: creating directory for file "+abs, errors.TypeFilesystem, errors.M(errors.MetaKeyPath, abs))
459+
return UnpackResult{}, goerrors.Join(err, errors.New("TarInstaller: creating directory for file "+abs, errors.TypeFilesystem, errors.M(errors.MetaKeyPath, abs)))
460460
}
461461
} else if err != nil {
462462
return UnpackResult{}, errors.New(err, "TarInstaller: stat() directory for file "+abs, errors.TypeFilesystem, errors.M(errors.MetaKeyPath, abs))
463463
} else {
464464
// directory already exists, set the appropriate permissions
465465
err = os.Chmod(abs, mode.Perm()&0770)
466466
if err != nil {
467-
return UnpackResult{}, errors.New(err, fmt.Sprintf("TarInstaller: setting permissions %O for directory %q", mode.Perm()&0770, abs), errors.TypeFilesystem, errors.M(errors.MetaKeyPath, abs))
467+
return UnpackResult{}, goerrors.Join(err, errors.New("TarInstaller: setting permissions %O for directory %q", mode.Perm()&0770, abs, errors.TypeFilesystem, errors.M(errors.MetaKeyPath, abs)))
468468
}
469469
}
470470
default:

0 commit comments

Comments
 (0)