chore: allow mounting files from the host

Allow mounting files from host into extension services as per the [OCI
spec](https://github.com/opencontainers/runtime-spec/blob/main/config.md#mounts)

Signed-off-by: Noel Georgi <git@frezbo.dev>
This commit is contained in:
Noel Georgi 2022-04-21 15:35:15 +05:30
parent f3e330a0aa
commit 51a68c31ff
No known key found for this signature in database
GPG Key ID: B1F736354201D483

View File

@ -6,6 +6,7 @@ package services
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
@ -102,6 +103,13 @@ func (svc *Extension) Runner(r runtime.Runtime) (runner.Runner, error) {
}
for _, mount := range svc.Spec.Container.Mounts {
if _, err := os.Stat(mount.Source); err == nil {
// already exists, skip
continue
} else if !errors.Is(err, os.ErrNotExist) {
return nil, err
}
if err := os.MkdirAll(mount.Source, 0o700); err != nil {
return nil, err
}