mirror of
https://github.com/containers/podman.git
synced 2025-06-25 12:20:42 +08:00
spec: move cgo stuff to their own file
so it can build without cgo since seccomp requires it. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -4,12 +4,10 @@ package createconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/profiles/seccomp"
|
||||
"github.com/opencontainers/runc/libcontainer/configs"
|
||||
"github.com/opencontainers/runc/libcontainer/devices"
|
||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
@ -130,29 +128,6 @@ func (c *CreateConfig) addPrivilegedDevices(g *generate.Generator) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getSeccompConfig(config *CreateConfig, configSpec *spec.Spec) (*spec.LinuxSeccomp, error) {
|
||||
var seccompConfig *spec.LinuxSeccomp
|
||||
var err error
|
||||
|
||||
if config.SeccompProfilePath != "" {
|
||||
seccompProfile, err := ioutil.ReadFile(config.SeccompProfilePath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "opening seccomp profile (%s) failed", config.SeccompProfilePath)
|
||||
}
|
||||
seccompConfig, err = seccomp.LoadProfile(string(seccompProfile), configSpec)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "loading seccomp profile (%s) failed", config.SeccompProfilePath)
|
||||
}
|
||||
} else {
|
||||
seccompConfig, err = seccomp.GetDefaultProfile(configSpec)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "loading seccomp profile (%s) failed", config.SeccompProfilePath)
|
||||
}
|
||||
}
|
||||
|
||||
return seccompConfig, nil
|
||||
}
|
||||
|
||||
func (c *CreateConfig) createBlockIO() (*spec.LinuxBlockIO, error) {
|
||||
var ret *spec.LinuxBlockIO
|
||||
bio := &spec.LinuxBlockIO{}
|
||||
|
34
pkg/spec/config_linux_cgo.go
Normal file
34
pkg/spec/config_linux_cgo.go
Normal file
@ -0,0 +1,34 @@
|
||||
// +build linux,cgo
|
||||
|
||||
package createconfig
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/docker/docker/profiles/seccomp"
|
||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func getSeccompConfig(config *CreateConfig, configSpec *spec.Spec) (*spec.LinuxSeccomp, error) {
|
||||
var seccompConfig *spec.LinuxSeccomp
|
||||
var err error
|
||||
|
||||
if config.SeccompProfilePath != "" {
|
||||
seccompProfile, err := ioutil.ReadFile(config.SeccompProfilePath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "opening seccomp profile (%s) failed", config.SeccompProfilePath)
|
||||
}
|
||||
seccompConfig, err = seccomp.LoadProfile(string(seccompProfile), configSpec)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "loading seccomp profile (%s) failed", config.SeccompProfilePath)
|
||||
}
|
||||
} else {
|
||||
seccompConfig, err = seccomp.GetDefaultProfile(configSpec)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "loading seccomp profile (%s) failed", config.SeccompProfilePath)
|
||||
}
|
||||
}
|
||||
|
||||
return seccompConfig, nil
|
||||
}
|
11
pkg/spec/config_linux_nocgo.go
Normal file
11
pkg/spec/config_linux_nocgo.go
Normal file
@ -0,0 +1,11 @@
|
||||
// +build linux,!cgo
|
||||
|
||||
package createconfig
|
||||
|
||||
import (
|
||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
func getSeccompConfig(config *CreateConfig, configSpec *spec.Spec) (*spec.LinuxSeccomp, error) {
|
||||
return nil, nil
|
||||
}
|
Reference in New Issue
Block a user