Fix docker.#Run compatibility with docker.#Build

Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
This commit is contained in:
Helder Correia 2022-01-15 19:33:50 -01:00
parent 5016f4597d
commit 3956b8b59b
No known key found for this signature in database
GPG Key ID: C6490D872EF1DCA7
2 changed files with 28 additions and 19 deletions

View File

@ -11,19 +11,19 @@ import (
output: #Image output: #Image
// Generate build DAG from linerar steps // Generate build DAG from linerar steps
dag: { _dag: {
for idx, step in steps { for idx, step in steps {
"\(idx)": step & { "\(idx)": step & {
// connect input to previous output // connect input to previous output
if idx > 0 { if idx > 0 {
input: dag["\(idx-1)"].output input: _dag["\(idx-1)"].output
} }
} }
} }
} }
if len(dag) > 0 { if len(_dag) > 0 {
output: dag["\(len(dag)-1)"].output output: _dag["\(len(_dag)-1)"].output
} }
} }

View File

@ -9,8 +9,16 @@ import (
// Run a command in a container // Run a command in a container
#Run: { #Run: {
_image: #Image
{
image: #Image image: #Image
input: image // for compatibility with #Build _image: image
} | {
// For compatibility with #Build
input: #Image
_image: input
}
always: bool | *false always: bool | *false
@ -94,34 +102,35 @@ import (
message: string | *null message: string | *null
} }
output?: { export: {
// FIXME: hack for #Build compatibility rootfs: dagger.#FS & _exec.output
#Image
rootfs?: dagger.#FS & _exec.output
files: [path=string]: { files: [path=string]: {
contents: string contents: string & _read.contents
contents: _read.contents
_read: engine.#ReadFile & { _read: engine.#ReadFile & {
input: _exec.output input: _exec.output
"path": path "path": path
} }
} }
directories: [path=string]: { directories: [path=string]: {
contents: dagger.#FS contents: dagger.#FS & _subdir.output
contents: (dagger.#Subdir & { _subdir: dagger.#Subdir & {
input: _exec.output input: _exec.output
"path": path "path": path
}).output
} }
} }
} }
}
// For compatibility with #Build
output: #Image & {
rootfs: _exec.output
config: _image.config
}
// Actually execute the command // Actually execute the command
_exec: engine.#Exec & { _exec: engine.#Exec & {
args: [cmd.name] + cmd._flatFlags + cmd.args args: [cmd.name] + cmd._flatFlags + cmd.args
input: image.rootfs input: _image.rootfs
"mounts": mounts "mounts": mounts
"env": env "env": env
"workdir": workdir "workdir": workdir