2018-11-06 05:39:48 +00:00
|
|
|
//+build !windows
|
|
|
|
|
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
2020-03-28 08:37:03 +00:00
|
|
|
"github.com/docker/docker/oci/caps"
|
2018-11-06 05:39:48 +00:00
|
|
|
docker "github.com/fsouza/go-dockerclient"
|
|
|
|
)
|
|
|
|
|
2021-02-03 03:54:23 +00:00
|
|
|
func getPortBinding(ip string, port string) docker.PortBinding {
|
|
|
|
return docker.PortBinding{HostIP: ip, HostPort: port}
|
2018-11-06 05:39:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func tweakCapabilities(basics, adds, drops []string) ([]string, error) {
|
|
|
|
// Moby mixes 2 different capabilities formats: prefixed with "CAP_"
|
|
|
|
// and not. We do the conversion here to have a consistent,
|
|
|
|
// non-prefixed format on the Nomad side.
|
|
|
|
for i, cap := range basics {
|
|
|
|
basics[i] = "CAP_" + cap
|
|
|
|
}
|
|
|
|
|
2020-03-28 08:37:03 +00:00
|
|
|
effectiveCaps, err := caps.TweakCapabilities(basics, adds, drops, nil, false)
|
2018-11-06 05:39:48 +00:00
|
|
|
if err != nil {
|
|
|
|
return effectiveCaps, err
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, cap := range effectiveCaps {
|
|
|
|
effectiveCaps[i] = cap[len("CAP_"):]
|
|
|
|
}
|
|
|
|
return effectiveCaps, nil
|
|
|
|
}
|