summaryrefslogtreecommitdiff
path: root/pkg/hooks/1.0.0
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/hooks/1.0.0')
-rw-r--r--pkg/hooks/1.0.0/hook.go8
-rw-r--r--pkg/hooks/1.0.0/when.go9
2 files changed, 9 insertions, 8 deletions
diff --git a/pkg/hooks/1.0.0/hook.go b/pkg/hooks/1.0.0/hook.go
index 244e8800f..71f940a64 100644
--- a/pkg/hooks/1.0.0/hook.go
+++ b/pkg/hooks/1.0.0/hook.go
@@ -3,12 +3,12 @@ package hook
import (
"encoding/json"
+ "errors"
"fmt"
"os"
"regexp"
rspec "github.com/opencontainers/runtime-spec/specs-go"
- "github.com/pkg/errors"
)
// Version is the hook configuration version defined in this package.
@@ -50,16 +50,16 @@ func (hook *Hook) Validate(extensionStages []string) (err error) {
for key, value := range hook.When.Annotations {
if _, err = regexp.Compile(key); err != nil {
- return errors.Wrapf(err, "invalid annotation key %q", key)
+ return fmt.Errorf("invalid annotation key %q: %w", key, err)
}
if _, err = regexp.Compile(value); err != nil {
- return errors.Wrapf(err, "invalid annotation value %q", value)
+ return fmt.Errorf("invalid annotation value %q: %w", value, err)
}
}
for _, command := range hook.When.Commands {
if _, err = regexp.Compile(command); err != nil {
- return errors.Wrapf(err, "invalid command %q", command)
+ return fmt.Errorf("invalid command %q: %w", command, err)
}
}
diff --git a/pkg/hooks/1.0.0/when.go b/pkg/hooks/1.0.0/when.go
index a65af048e..a1351890f 100644
--- a/pkg/hooks/1.0.0/when.go
+++ b/pkg/hooks/1.0.0/when.go
@@ -1,10 +1,11 @@
package hook
import (
+ "errors"
+ "fmt"
"regexp"
rspec "github.com/opencontainers/runtime-spec/specs-go"
- "github.com/pkg/errors"
)
// When holds hook-injection conditions.
@@ -52,12 +53,12 @@ func (when *When) Match(config *rspec.Spec, annotations map[string]string, hasBi
for key, value := range annotations {
match, err = regexp.MatchString(keyPattern, key)
if err != nil {
- return false, errors.Wrap(err, "annotation key")
+ return false, fmt.Errorf("annotation key: %w", err)
}
if match {
match, err = regexp.MatchString(valuePattern, value)
if err != nil {
- return false, errors.Wrap(err, "annotation value")
+ return false, fmt.Errorf("annotation value: %w", err)
}
if match {
break
@@ -82,7 +83,7 @@ func (when *When) Match(config *rspec.Spec, annotations map[string]string, hasBi
for _, cmdPattern := range when.Commands {
match, err := regexp.MatchString(cmdPattern, command)
if err != nil {
- return false, errors.Wrap(err, "command")
+ return false, fmt.Errorf("command: %w", err)
}
if match {
return true, nil