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

Commit

Permalink
Unify errors for unsupported seccomp
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
saschagrunert committed Aug 5, 2020
1 parent 80216ab commit e208829
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions seccomp_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,36 @@
package seccomp // import "github.com/seccomp/containers-golang"

import (
"fmt"
"errors"

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

var errNotSupported = errors.New("seccomp not enabled in this build")

// DefaultProfile returns a nil pointer on unsupported systems.
func DefaultProfile() *Seccomp {
return nil
}

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

// GetDefaultProfile returns an error on unsuppored systems
func GetDefaultProfile(rs *specs.Spec) (*specs.LinuxSeccomp, error) {
return nil, fmt.Errorf("Seccomp not supported on this platform")
return nil, errNotSupported
}

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

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

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

0 comments on commit e208829

Please sign in to comment.