-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
42 lines (38 loc) · 1.03 KB
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package secfs
import (
"errors"
"io/fs"
"os"
"syscall"
)
var (
// ErrMoveCrossNamespace is currently not allowed
ErrMoveCrossNamespace = errors.New("move a secret between namespaces is not allowed")
// ErrMoveConvert secrets can contain files only
ErrMoveConvert = errors.New("convert a secret to a file is not allowed")
)
func wrapPathError(op, name string, err error) error {
switch err {
case nil:
return nil
case syscall.EEXIST:
return &os.PathError{Op: op, Path: name, Err: fs.ErrExist}
case syscall.ENOENT:
return &os.PathError{Op: op, Path: name, Err: fs.ErrNotExist}
default:
return &os.PathError{Op: op, Path: name, Err: err}
}
}
//nolint:unparam // op is currently only "Rename"
func wrapLinkError(op, o, n string, err error) error {
switch err {
case nil:
return nil
case syscall.EEXIST:
return &os.LinkError{Op: op, Old: o, New: n, Err: fs.ErrExist}
case syscall.ENOENT:
return &os.LinkError{Op: op, Old: o, New: n, Err: fs.ErrNotExist}
default:
return &os.LinkError{Op: op, Old: o, New: n, Err: err}
}
}