Merge pull request #1438 from helderco/fix-run

Fix docker.#Run compatibility with docker.#Build
This commit is contained in:
Solomon Hykes 2022-01-18 11:00:31 -08:00 committed by GitHub
commit 6162962b97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
input: image // for compatibility with #Build
{
image: #Image
_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