support for defining docker network opts
This commit is contained in:
@@ -52,6 +52,7 @@ type Config struct {
|
||||
Volumes map[string]string `envconfig:"DRONE_RUNNER_VOLUMES"`
|
||||
Devices []string `envconfig:"DRONE_RUNNER_DEVICES"`
|
||||
Networks []string `envconfig:"DRONE_RUNNER_NETWORKS"`
|
||||
NetworkOpts map[string]string `envconfig:"DRONE_RUNNER_NETWORK_OPTS"`
|
||||
Privileged []string `envconfig:"DRONE_RUNNER_PRIVILEGED_IMAGES"`
|
||||
Clone string `envconfig:"DRONE_RUNNER_CLONE_IMAGE"`
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
|
||||
Clone: config.Runner.Clone,
|
||||
Privileged: append(config.Runner.Privileged, compiler.Privileged...),
|
||||
Networks: config.Runner.Networks,
|
||||
NetworkOpts: config.Runner.NetworkOpts,
|
||||
Volumes: config.Runner.Volumes,
|
||||
Resources: compiler.Resources{
|
||||
Memory: config.Resources.Memory,
|
||||
|
||||
@@ -73,6 +73,10 @@ type Compiler struct {
|
||||
// attached to each pipeline container.
|
||||
Networks []string
|
||||
|
||||
// NetworkOpts provides a set of network options that
|
||||
// are used when creating the docker network.
|
||||
NetworkOpts map[string]string
|
||||
|
||||
// Volumes provides a set of volumes that should be
|
||||
// mounted to each pipeline container.
|
||||
Volumes map[string]string
|
||||
@@ -156,6 +160,7 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
|
||||
Network: engine.Network{
|
||||
ID: random(),
|
||||
Labels: labels,
|
||||
Options: c.NetworkOpts,
|
||||
},
|
||||
Platform: engine.Platform{
|
||||
OS: pipeline.Platform.OS,
|
||||
|
||||
@@ -84,6 +84,7 @@ func (e *Docker) Setup(ctx context.Context, specv runtime.Spec) error {
|
||||
}
|
||||
_, err := e.client.NetworkCreate(ctx, spec.Network.ID, types.NetworkCreate{
|
||||
Driver: driver,
|
||||
Options: spec.Network.Options,
|
||||
Labels: spec.Network.Labels,
|
||||
})
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ type (
|
||||
Network struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
Options map[string]string `json:"options,omitempty"`
|
||||
}
|
||||
|
||||
// Auth defines dockerhub authentication credentials.
|
||||
|
||||
Reference in New Issue
Block a user