87a12421a9
Instead of having to create a bunch of custom error types that are doing nothing but wrapping another error in sub-packages, use a common helper to create errors of the requested type. e.g. instead of re-implementing this over and over: ```go type notFoundError struct { cause error } func(e notFoundError) Error() string { return e.cause.Error() } func(e notFoundError) NotFound() {} func(e notFoundError) Cause() error { return e.cause } ``` Packages can instead just do: ``` errdefs.NotFound(err) ``` Signed-off-by: Brian Goff <cpuguy83@gmail.com>
30 lines
709 B
Go
30 lines
709 B
Go
//+build !windows
|
|
|
|
package daemon
|
|
|
|
import (
|
|
"github.com/docker/docker/api/errdefs"
|
|
"github.com/docker/docker/container"
|
|
)
|
|
|
|
func (daemon *Daemon) saveApparmorConfig(container *container.Container) error {
|
|
container.AppArmorProfile = "" //we don't care about the previous value.
|
|
|
|
if !daemon.apparmorEnabled {
|
|
return nil // if apparmor is disabled there is nothing to do here.
|
|
}
|
|
|
|
if err := parseSecurityOpt(container, container.HostConfig); err != nil {
|
|
return errdefs.InvalidParameter(err)
|
|
}
|
|
|
|
if !container.HostConfig.Privileged {
|
|
if container.AppArmorProfile == "" {
|
|
container.AppArmorProfile = defaultApparmorProfile
|
|
}
|
|
|
|
} else {
|
|
container.AppArmorProfile = "unconfined"
|
|
}
|
|
return nil
|
|
}
|