diff --git a/pkg/dagger.io/dagger/engine/fs.cue b/pkg/dagger.io/dagger/engine/fs.cue index c984b5bc..51fd8927 100644 --- a/pkg/dagger.io/dagger/engine/fs.cue +++ b/pkg/dagger.io/dagger/engine/fs.cue @@ -69,9 +69,15 @@ package engine // Copy files from one FS tree to another #Copy: { $dagger: task: _name: "Copy" - + // Input of the operation input: #FS - #CopyInfo + // Contents to copy + contents: #FS + // Source path (optional) + source: string | *"/" + // Destination path (optional) + dest: string | *"/" + // Output of the operation output: #FS } diff --git a/pkg/dagger.io/dagger/utils.cue b/pkg/dagger.io/dagger/utils.cue index 43e64f67..b623476c 100644 --- a/pkg/dagger.io/dagger/utils.cue +++ b/pkg/dagger.io/dagger/utils.cue @@ -25,12 +25,10 @@ import ( // Copy action _copy: engine.#Copy & { - "input": engine.#Scratch - source: { - root: input - "path": path - } - dest: "/" + "input": engine.#Scratch + contents: input + source: path + dest: "/" } // Subdirectory tree diff --git a/pkg/universe.dagger.io/docker/build.cue b/pkg/universe.dagger.io/docker/build.cue index fa58e9d9..d49b5496 100644 --- a/pkg/universe.dagger.io/docker/build.cue +++ b/pkg/universe.dagger.io/docker/build.cue @@ -48,12 +48,10 @@ import ( // Execute copy operation _copy: engine.#Copy & { - "input": input.rootfs - "source": { - root: contents - path: source - } - "dest": dest + "input": input.rootfs + "contents": contents + "source": source + "dest": dest } output: #Image & { diff --git a/pkg/universe.dagger.io/examples/changelog.com/lowlevel/main.cue b/pkg/universe.dagger.io/examples/changelog.com/lowlevel/main.cue index ffb0e9a7..273de6d9 100644 --- a/pkg/universe.dagger.io/examples/changelog.com/lowlevel/main.cue +++ b/pkg/universe.dagger.io/examples/changelog.com/lowlevel/main.cue @@ -98,9 +98,9 @@ engine.#Plan & { } appImage: engine.#Copy & { - input: runtimeImage.output - source: root: inputs.directories.app.contents - dest: "/app" + input: runtimeImage.output + contents: inputs.directories.app.contents + dest: "/app" } deps: engine.#Exec & { diff --git a/plan/task/copy.go b/plan/task/copy.go index 81182c01..dc6b8995 100644 --- a/plan/task/copy.go +++ b/plan/task/copy.go @@ -29,17 +29,17 @@ func (t *copyTask) Run(ctx context.Context, pctx *plancontext.Context, s solver. return nil, err } - sourceRoot, err := pctx.FS.FromValue(v.Lookup("source.root")) + contents, err := pctx.FS.FromValue(v.Lookup("contents")) if err != nil { return nil, err } - sourceState, err := sourceRoot.State() + contentsState, err := contents.State() if err != nil { return nil, err } - sourcePath, err := v.Lookup("source.path").String() + sourcePath, err := v.Lookup("source").String() if err != nil { return nil, err } @@ -51,7 +51,7 @@ func (t *copyTask) Run(ctx context.Context, pctx *plancontext.Context, s solver. outputState := inputState.File( llb.Copy( - sourceState, + contentsState, sourcePath, destPath, // FIXME: allow more configurable llb options diff --git a/tests/tasks/copy/copy_exec.cue b/tests/tasks/copy/copy_exec.cue index 18639639..97cc1bf6 100644 --- a/tests/tasks/copy/copy_exec.cue +++ b/tests/tasks/copy/copy_exec.cue @@ -29,13 +29,12 @@ engine.#Plan & { } copy: engine.#Copy & { - input: image.output - source: { - root: exec.output - path: "/output.txt" - } - dest: "/output.txt" + input: image.output + contents: exec.output + source: "/output.txt" + dest: "/output.txt" } + verify_copy: engine.#ReadFile & { input: copy.output path: "/output.txt" diff --git a/tests/tasks/copy/copy_exec_invalid.cue b/tests/tasks/copy/copy_exec_invalid.cue index ef669620..f5754dc5 100644 --- a/tests/tasks/copy/copy_exec_invalid.cue +++ b/tests/tasks/copy/copy_exec_invalid.cue @@ -29,12 +29,10 @@ engine.#Plan & { } copy: engine.#Copy & { - input: image.output - source: { - root: exec.output - path: "/output.txt" - } - dest: "/output.txt" + input: image.output + contents: exec.output + source: "/output.txt" + dest: "/output.txt" } verify_copy: engine.#ReadFile & { input: copy.output diff --git a/tests/tasks/copy/copy_file.cue b/tests/tasks/copy/copy_file.cue index ac95ea19..6a08c10b 100644 --- a/tests/tasks/copy/copy_file.cue +++ b/tests/tasks/copy/copy_file.cue @@ -23,12 +23,10 @@ engine.#Plan & { } copy: engine.#Copy & { - input: busybox1_34_1.output - source: { - root: alpine3_15_0.output - path: "/etc/alpine-release" - } - dest: "/alpine3_15_0_release" + input: busybox1_34_1.output + contents: alpine3_15_0.output + source: "/etc/alpine-release" + dest: "/alpine3_15_0_release" } verify_copy: engine.#ReadFile & {