mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-10-19 05:39:51 +00:00
91774fc936
Uses github.com/libopenstorage/secrets to communicate with Vault. This removes the need for maintaining our own limited Vault APIs. By adding the new dependency, several other packages got updated in the process. Unused indirect dependencies have been removed from go.mod. Signed-off-by: Niels de Vos <ndevos@redhat.com>
27 lines
568 B
Go
27 lines
568 B
Go
package multierror
|
|
|
|
// Flatten flattens the given error, merging any *Errors together into
|
|
// a single *Error.
|
|
func Flatten(err error) error {
|
|
// If it isn't an *Error, just return the error as-is
|
|
if _, ok := err.(*Error); !ok {
|
|
return err
|
|
}
|
|
|
|
// Otherwise, make the result and flatten away!
|
|
flatErr := new(Error)
|
|
flatten(err, flatErr)
|
|
return flatErr
|
|
}
|
|
|
|
func flatten(err error, flatErr *Error) {
|
|
switch err := err.(type) {
|
|
case *Error:
|
|
for _, e := range err.Errors {
|
|
flatten(e, flatErr)
|
|
}
|
|
default:
|
|
flatErr.Errors = append(flatErr.Errors, err)
|
|
}
|
|
}
|