inputs: pre-defined input paths
Instead of bind-mounting each individual input into the container,
create a temporary directory that is used by all inputs and bind-
mount this to the well known location ("/run/osbuild/inputs"). The
temporary directory is then passed to the input so that it can
make the requested resources available relative to that directory.
This is enforced by the common input handling code.
Additionally, pass the well known input path via a new "paths" key
to the arguments dictionary passed to the stage.
This commit is contained in:
parent
47fefe7e2d
commit
08bc9ab7d8
6 changed files with 45 additions and 28 deletions
|
|
@ -25,6 +25,7 @@ import subprocess
|
|||
|
||||
from typing import Dict, Optional, Tuple
|
||||
|
||||
from osbuild.util.types import PathLike
|
||||
from .objectstore import StoreServer
|
||||
|
||||
|
||||
|
|
@ -58,13 +59,19 @@ class Input:
|
|||
m.update(json.dumps(self.options, sort_keys=True).encode())
|
||||
return m.hexdigest()
|
||||
|
||||
def run(self, storeapi: StoreServer) -> Tuple[str, Dict]:
|
||||
def run(self, storeapi: StoreServer, root: PathLike) -> Tuple[str, Dict]:
|
||||
name = self.info.name
|
||||
|
||||
target = os.path.join(root, self.name)
|
||||
os.makedirs(target)
|
||||
|
||||
msg = {
|
||||
# mandatory bits
|
||||
"origin": self.origin,
|
||||
"refs": self.refs,
|
||||
|
||||
"target": target,
|
||||
|
||||
# global options
|
||||
"options": self.options,
|
||||
|
||||
|
|
@ -101,6 +108,11 @@ class Input:
|
|||
if r.returncode != 0:
|
||||
raise RuntimeError(f"{name}: error {r.returncode}")
|
||||
|
||||
path, data = reply["path"], reply.get("data", {})
|
||||
path = reply["path"]
|
||||
|
||||
return path, data
|
||||
if not path.startswith(root):
|
||||
raise RuntimeError(f"returned {path} has wrong prefix")
|
||||
|
||||
reply["path"] = os.path.relpath(path, root)
|
||||
|
||||
return reply
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue