eventmanager: allow to access the backup file

so it can be used in email and other actions

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-10-29 14:04:31 +02:00
parent 9a9e7d1a7f
commit 80244bd83b
7 changed files with 171 additions and 16 deletions

View File

@@ -727,3 +727,19 @@ func PanicOnError(err error) {
panic(fmt.Errorf("unexpected error: %w", err))
}
}
// GetAbsolutePath returns an absolute path using the current dir as base
// if name defines a relative path
func GetAbsolutePath(name string) (string, error) {
if name == "" {
return name, errors.New("input path cannot be empty")
}
if filepath.IsAbs(name) {
return name, nil
}
curDir, err := os.Getwd()
if err != nil {
return name, err
}
return filepath.Join(curDir, name), nil
}