Merge pull request #1521 from talentedmrjones/europa-engine-copy-docker-copy

engine.#Copy matches docker.#Copy
This commit is contained in:
Richard Jones 2022-01-28 10:25:47 -07:00 committed by GitHub
commit f47d44da79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 36 additions and 39 deletions

View File

@ -69,9 +69,15 @@ package engine
// Copy files from one FS tree to another // Copy files from one FS tree to another
#Copy: { #Copy: {
$dagger: task: _name: "Copy" $dagger: task: _name: "Copy"
// Input of the operation
input: #FS input: #FS
#CopyInfo // Contents to copy
contents: #FS
// Source path (optional)
source: string | *"/"
// Destination path (optional)
dest: string | *"/"
// Output of the operation
output: #FS output: #FS
} }

View File

@ -25,12 +25,10 @@ import (
// Copy action // Copy action
_copy: engine.#Copy & { _copy: engine.#Copy & {
"input": engine.#Scratch "input": engine.#Scratch
source: { contents: input
root: input source: path
"path": path dest: "/"
}
dest: "/"
} }
// Subdirectory tree // Subdirectory tree

View File

@ -48,12 +48,10 @@ import (
// Execute copy operation // Execute copy operation
_copy: engine.#Copy & { _copy: engine.#Copy & {
"input": input.rootfs "input": input.rootfs
"source": { "contents": contents
root: contents "source": source
path: source "dest": dest
}
"dest": dest
} }
output: #Image & { output: #Image & {

View File

@ -98,9 +98,9 @@ engine.#Plan & {
} }
appImage: engine.#Copy & { appImage: engine.#Copy & {
input: runtimeImage.output input: runtimeImage.output
source: root: inputs.directories.app.contents contents: inputs.directories.app.contents
dest: "/app" dest: "/app"
} }
deps: engine.#Exec & { deps: engine.#Exec & {

View File

@ -29,17 +29,17 @@ func (t *copyTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.
return nil, err return nil, err
} }
sourceRoot, err := pctx.FS.FromValue(v.Lookup("source.root")) contents, err := pctx.FS.FromValue(v.Lookup("contents"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
sourceState, err := sourceRoot.State() contentsState, err := contents.State()
if err != nil { if err != nil {
return nil, err return nil, err
} }
sourcePath, err := v.Lookup("source.path").String() sourcePath, err := v.Lookup("source").String()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -51,7 +51,7 @@ func (t *copyTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.
outputState := inputState.File( outputState := inputState.File(
llb.Copy( llb.Copy(
sourceState, contentsState,
sourcePath, sourcePath,
destPath, destPath,
// FIXME: allow more configurable llb options // FIXME: allow more configurable llb options

View File

@ -29,13 +29,12 @@ engine.#Plan & {
} }
copy: engine.#Copy & { copy: engine.#Copy & {
input: image.output input: image.output
source: { contents: exec.output
root: exec.output source: "/output.txt"
path: "/output.txt" dest: "/output.txt"
}
dest: "/output.txt"
} }
verify_copy: engine.#ReadFile & { verify_copy: engine.#ReadFile & {
input: copy.output input: copy.output
path: "/output.txt" path: "/output.txt"

View File

@ -29,12 +29,10 @@ engine.#Plan & {
} }
copy: engine.#Copy & { copy: engine.#Copy & {
input: image.output input: image.output
source: { contents: exec.output
root: exec.output source: "/output.txt"
path: "/output.txt" dest: "/output.txt"
}
dest: "/output.txt"
} }
verify_copy: engine.#ReadFile & { verify_copy: engine.#ReadFile & {
input: copy.output input: copy.output

View File

@ -23,12 +23,10 @@ engine.#Plan & {
} }
copy: engine.#Copy & { copy: engine.#Copy & {
input: busybox1_34_1.output input: busybox1_34_1.output
source: { contents: alpine3_15_0.output
root: alpine3_15_0.output source: "/etc/alpine-release"
path: "/etc/alpine-release" dest: "/alpine3_15_0_release"
}
dest: "/alpine3_15_0_release"
} }
verify_copy: engine.#ReadFile & { verify_copy: engine.#ReadFile & {