Skip to content
This repository was archived by the owner on Aug 28, 2020. It is now read-only.

Commit e208829

Browse files
committed
Unify errors for unsupported seccomp
To remove the message repetition we now use a global error type to avoid the noise. We also change the error message to point out that its not enabled by the build, but may be enabled by the host. Signed-off-by: Sascha Grunert <[email protected]>
1 parent 80216ab commit e208829

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

seccomp_unsupported.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,36 @@
77
package seccomp // import "github.com/seccomp/containers-golang"
88

99
import (
10-
"fmt"
10+
"errors"
1111

1212
"github.com/opencontainers/runtime-spec/specs-go"
1313
)
1414

15+
var errNotSupported = errors.New("seccomp not enabled in this build")
16+
1517
// DefaultProfile returns a nil pointer on unsupported systems.
1618
func DefaultProfile() *Seccomp {
1719
return nil
1820
}
1921

2022
// LoadProfile returns an error on unsuppored systems
2123
func LoadProfile(body string, rs *specs.Spec) (*specs.LinuxSeccomp, error) {
22-
return nil, fmt.Errorf("Seccomp not supported on this platform")
24+
return nil, errNotSupported
2325
}
2426

2527
// GetDefaultProfile returns an error on unsuppored systems
2628
func GetDefaultProfile(rs *specs.Spec) (*specs.LinuxSeccomp, error) {
27-
return nil, fmt.Errorf("Seccomp not supported on this platform")
29+
return nil, errNotSupported
2830
}
2931

3032
// LoadProfileFromBytes takes a byte slice and decodes the seccomp profile.
3133
func LoadProfileFromBytes(body []byte, rs *specs.Spec) (*specs.LinuxSeccomp, error) {
32-
return nil, fmt.Errorf("Seccomp not supported on this platform")
34+
return nil, errNotSupported
3335
}
3436

3537
// LoadProfileFromConfig takes a Seccomp struct and a spec to retrieve a LinuxSeccomp
3638
func LoadProfileFromConfig(config *Seccomp, specgen *specs.Spec) (*specs.LinuxSeccomp, error) {
37-
return nil, fmt.Errorf("Seccomp not supported on this platform")
39+
return nil, errNotSupported
3840
}
3941

4042
// IsEnabled returns true if seccomp is enabled for the host.

0 commit comments

Comments
 (0)