support :ro suffix for volumes
This commit is contained in:
@@ -7,6 +7,7 @@ package compiler
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/drone-runners/drone-runner-docker/engine"
|
"github.com/drone-runners/drone-runner-docker/engine"
|
||||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||||
@@ -366,16 +367,14 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
|
|||||||
// append global volumes to the steps.
|
// append global volumes to the steps.
|
||||||
for k, v := range c.Volumes {
|
for k, v := range c.Volumes {
|
||||||
id := random()
|
id := random()
|
||||||
|
ro := strings.HasSuffix(v, ":ro")
|
||||||
|
v = strings.TrimSuffix(v, ":ro")
|
||||||
volume := &engine.Volume{
|
volume := &engine.Volume{
|
||||||
HostPath: &engine.VolumeHostPath{
|
HostPath: &engine.VolumeHostPath{
|
||||||
ID: id,
|
ID: id,
|
||||||
Name: id,
|
Name: id,
|
||||||
Path: k,
|
Path: k,
|
||||||
|
ReadOnly: ro,
|
||||||
// TODO(bradrydzewski) the volume map does not include
|
|
||||||
// a read only flag and needs to be modified to provide
|
|
||||||
// this option.
|
|
||||||
ReadOnly: false,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
spec.Volumes = append(spec.Volumes, volume)
|
spec.Volumes = append(spec.Volumes, volume)
|
||||||
|
|||||||
Reference in New Issue
Block a user