mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-20 23:26:34 +00:00
Implement read only flag
Signed-off-by: Peter Mills <ptjm8422@gmail.com> Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
@ -57,8 +57,14 @@ type ServicePort struct {
|
||||
}
|
||||
|
||||
type Mount struct {
|
||||
// Src relative to the working directory for faasd
|
||||
Src string
|
||||
|
||||
// Dest is the absolute path within the container
|
||||
Dest string
|
||||
|
||||
// ReadOnly when set to true indicates the mount will be set to "ro" instead of "rw"
|
||||
ReadOnly bool
|
||||
}
|
||||
|
||||
type Supervisor struct {
|
||||
@ -151,11 +157,18 @@ func (s *Supervisor) Start(svcs []Service) error {
|
||||
mounts := []specs.Mount{}
|
||||
if len(svc.Mounts) > 0 {
|
||||
for _, mnt := range svc.Mounts {
|
||||
var options = []string{"rbind"}
|
||||
if mnt.ReadOnly {
|
||||
options = append(options, "ro")
|
||||
} else {
|
||||
options = append(options, "rw")
|
||||
}
|
||||
|
||||
mounts = append(mounts, specs.Mount{
|
||||
Source: mnt.Src,
|
||||
Destination: mnt.Dest,
|
||||
Type: "bind",
|
||||
Options: []string{"rbind", "rw"},
|
||||
Options: options,
|
||||
})
|
||||
|
||||
// Only create directories, not files.
|
||||
@ -344,6 +357,7 @@ func ParseCompose(config *compose.Config) ([]Service, error) {
|
||||
mounts = append(mounts, Mount{
|
||||
Src: v.Source,
|
||||
Dest: v.Target,
|
||||
ReadOnly: v.ReadOnly,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ func equalMountSlice(t *testing.T, want, found []Mount) {
|
||||
|
||||
for i := range want {
|
||||
if !reflect.DeepEqual(want[i], found[i]) {
|
||||
t.Fatalf("unexpected value at postition %d: want %s, got %s", i, want[i], found[i])
|
||||
t.Fatalf("unexpected value at postition %d: want %v, got %v", i, want[i], found[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user