diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-09-29 19:10:57 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-09-29 20:48:49 +1000 |
commit | 1759ddf2470389d8de7ccedad24caf66c3cdb7d5 (patch) | |
tree | 728215e1a6a2e60580ac905b1709f67a38f1814c /pkg/utils | |
parent | f9643448a4ba186fb56d408a5ee8a21193986cd6 (diff) |
move OS commands into their own package
Diffstat (limited to 'pkg/utils')
-rw-r--r-- | pkg/utils/dummies.go | 14 | ||||
-rw-r--r-- | pkg/utils/errors.go | 14 |
2 files changed, 28 insertions, 0 deletions
diff --git a/pkg/utils/dummies.go b/pkg/utils/dummies.go new file mode 100644 index 000000000..ab6d041dd --- /dev/null +++ b/pkg/utils/dummies.go @@ -0,0 +1,14 @@ +package utils + +import ( + "io/ioutil" + + "github.com/sirupsen/logrus" +) + +// NewDummyLog creates a new dummy Log for testing +func NewDummyLog() *logrus.Entry { + log := logrus.New() + log.Out = ioutil.Discard + return log.WithField("test", "test") +} diff --git a/pkg/utils/errors.go b/pkg/utils/errors.go new file mode 100644 index 000000000..cd3cb686c --- /dev/null +++ b/pkg/utils/errors.go @@ -0,0 +1,14 @@ +package utils + +import "github.com/go-errors/errors" + +// WrapError wraps an error for the sake of showing a stack trace at the top level +// the go-errors package, for some reason, does not return nil when you try to wrap +// a non-error, so we're just doing it here +func WrapError(err error) error { + if err == nil { + return err + } + + return errors.Wrap(err, 0) +} |