2016-07-27 21:57:40 +00:00
|
|
|
//+build !windows
|
|
|
|
|
|
|
|
package driver
|
|
|
|
|
2018-01-21 11:14:24 +00:00
|
|
|
import (
|
|
|
|
docker "github.com/fsouza/go-dockerclient"
|
|
|
|
"github.com/moby/moby/daemon/caps"
|
|
|
|
)
|
2016-07-27 21:57:40 +00:00
|
|
|
|
2016-08-04 21:11:06 +00:00
|
|
|
const (
|
2016-08-05 17:47:44 +00:00
|
|
|
// Setting default network mode for non-windows OS as bridge
|
2016-08-04 21:11:06 +00:00
|
|
|
defaultNetworkMode = "bridge"
|
|
|
|
)
|
|
|
|
|
2016-07-27 21:57:40 +00:00
|
|
|
func getPortBinding(ip string, port string) []docker.PortBinding {
|
2017-09-26 22:26:33 +00:00
|
|
|
return []docker.PortBinding{{HostIP: ip, HostPort: port}}
|
2016-07-27 21:57:40 +00:00
|
|
|
}
|
2018-01-21 11:14:24 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
effectiveCaps, err := caps.TweakCapabilities(basics, adds, drops)
|
|
|
|
if err != nil {
|
|
|
|
return effectiveCaps, err
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, cap := range effectiveCaps {
|
|
|
|
effectiveCaps[i] = cap[len("CAP_"):]
|
|
|
|
}
|
|
|
|
return effectiveCaps, nil
|
|
|
|
}
|