From 3956b8b59b70657901be16366a2e5cf4b77ed55c Mon Sep 17 00:00:00 2001 From: Helder Correia <174525+helderco@users.noreply.github.com> Date: Sat, 15 Jan 2022 19:33:50 -0100 Subject: [PATCH] Fix docker.#Run compatibility with docker.#Build Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com> --- pkg/universe.dagger.io/docker/build.cue | 8 ++--- pkg/universe.dagger.io/docker/run.cue | 39 +++++++++++++++---------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/pkg/universe.dagger.io/docker/build.cue b/pkg/universe.dagger.io/docker/build.cue index 019a75fe..16e0724b 100644 --- a/pkg/universe.dagger.io/docker/build.cue +++ b/pkg/universe.dagger.io/docker/build.cue @@ -11,19 +11,19 @@ import ( output: #Image // Generate build DAG from linerar steps - dag: { + _dag: { for idx, step in steps { "\(idx)": step & { // connect input to previous output if idx > 0 { - input: dag["\(idx-1)"].output + input: _dag["\(idx-1)"].output } } } } - if len(dag) > 0 { - output: dag["\(len(dag)-1)"].output + if len(_dag) > 0 { + output: _dag["\(len(_dag)-1)"].output } } diff --git a/pkg/universe.dagger.io/docker/run.cue b/pkg/universe.dagger.io/docker/run.cue index 6decc348..3a16efe5 100644 --- a/pkg/universe.dagger.io/docker/run.cue +++ b/pkg/universe.dagger.io/docker/run.cue @@ -9,8 +9,16 @@ import ( // Run a command in a container #Run: { - image: #Image - input: image // for compatibility with #Build + _image: #Image + + { + image: #Image + _image: image + } | { + // For compatibility with #Build + input: #Image + _image: input + } always: bool | *false @@ -94,34 +102,35 @@ import ( message: string | *null } - output?: { - // FIXME: hack for #Build compatibility - #Image - - rootfs?: dagger.#FS & _exec.output + export: { + rootfs: dagger.#FS & _exec.output files: [path=string]: { - contents: string - contents: _read.contents - - _read: engine.#ReadFile & { + contents: string & _read.contents + _read: engine.#ReadFile & { input: _exec.output "path": path } } directories: [path=string]: { - contents: dagger.#FS - contents: (dagger.#Subdir & { + contents: dagger.#FS & _subdir.output + _subdir: dagger.#Subdir & { input: _exec.output "path": path - }).output + } } } } + // For compatibility with #Build + output: #Image & { + rootfs: _exec.output + config: _image.config + } + // Actually execute the command _exec: engine.#Exec & { args: [cmd.name] + cmd._flatFlags + cmd.args - input: image.rootfs + input: _image.rootfs "mounts": mounts "env": env "workdir": workdir