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