diff --git a/europa-universe/yarn/tests/simple/simple.cue b/europa-universe/yarn/tests/simple/simple.cue index ce8771b8..19d771b1 100644 --- a/europa-universe/yarn/tests/simple/simple.cue +++ b/europa-universe/yarn/tests/simple/simple.cue @@ -5,7 +5,7 @@ import ( ) b: #Build & { - source: engine.#Scratch.output + source: engine.#Scratch } out: b.output diff --git a/plan/task/scratch.go b/plan/task/scratch.go deleted file mode 100644 index 5c01d626..00000000 --- a/plan/task/scratch.go +++ /dev/null @@ -1,24 +0,0 @@ -package task - -import ( - "context" - - "go.dagger.io/dagger/compiler" - "go.dagger.io/dagger/plancontext" - "go.dagger.io/dagger/solver" -) - -func init() { - Register("Scratch", func() Task { return &scratchTask{} }) -} - -type scratchTask struct { -} - -func (t *scratchTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) { - fs := pctx.FS.New(nil) - - return compiler.NewValue().FillFields(map[string]interface{}{ - "output": fs.MarshalCUE(), - }) -} diff --git a/plancontext/fs.go b/plancontext/fs.go index a8f4009f..a0b712fd 100644 --- a/plancontext/fs.go +++ b/plancontext/fs.go @@ -71,6 +71,11 @@ func (c *fsContext) FromValue(v *compiler.Value) (*FS, error) { c.l.RLock() defer c.l.RUnlock() + // This is #Scratch, so we'll return an empty FS + if v.LookupPath(fsIDPath).Kind() == cue.NullKind { + return &FS{}, nil + } + id, err := v.LookupPath(fsIDPath).String() if err != nil { return nil, fmt.Errorf("invalid FS %q: %w", v.Path(), err) diff --git a/stdlib/europa/dagger/engine/fs.cue b/stdlib/europa/dagger/engine/fs.cue index ff4d1d7a..bba15ec3 100644 --- a/stdlib/europa/dagger/engine/fs.cue +++ b/stdlib/europa/dagger/engine/fs.cue @@ -49,11 +49,7 @@ package engine } // Produce an empty directory -#Scratch: { - $dagger: task: _name: "Scratch" - - output: #FS -} +#Scratch: {$dagger: fs: _id: null} // Copy files from one FS tree to another #Copy: { diff --git a/stdlib/europa/dagger/engine/types.cue b/stdlib/europa/dagger/engine/types.cue index 7296f3fb..4c13245c 100644 --- a/stdlib/europa/dagger/engine/types.cue +++ b/stdlib/europa/dagger/engine/types.cue @@ -7,7 +7,7 @@ package engine // - A directory containing binary artifacts // Rule of thumb: if it fits in a tar archive, it fits in a #FS. #FS: { - $dagger: fs: _id: string + $dagger: fs: _id: string | null } // A reference to an external secret, for example: diff --git a/stdlib/europa/dagger/utils.cue b/stdlib/europa/dagger/utils.cue index b69f7b96..2f8a9f0a 100644 --- a/stdlib/europa/dagger/utils.cue +++ b/stdlib/europa/dagger/utils.cue @@ -16,12 +16,9 @@ import ( // Subdirectory tree output: #FS & copy.output - // Base image - scratch: engine.#Scratch - // Copy action copy: engine.#Copy & { - "input": scratch.output + "input": engine.#Scratch source: { root: input "path": path diff --git a/tests/cue.mod/module.cue b/tests/cue.mod/module.cue new file mode 100644 index 00000000..f8af9cef --- /dev/null +++ b/tests/cue.mod/module.cue @@ -0,0 +1 @@ +module: "" diff --git a/tests/cue.mod/pkg/.gitignore b/tests/cue.mod/pkg/.gitignore new file mode 100644 index 00000000..2d4dc1ae --- /dev/null +++ b/tests/cue.mod/pkg/.gitignore @@ -0,0 +1,3 @@ +# generated by dagger +alpha.dagger.io +dagger.lock diff --git a/tests/plan/outputs/outputs.cue b/tests/plan/outputs/outputs.cue index 30101e8f..962d36aa 100644 --- a/tests/plan/outputs/outputs.cue +++ b/tests/plan/outputs/outputs.cue @@ -4,10 +4,8 @@ import "alpha.dagger.io/europa/dagger/engine" engine.#Plan & { actions: { - scratch: engine.#Scratch - data: engine.#WriteFile & { - input: scratch.output + input: engine.#Scratch path: "/test" permissions: 0o600 contents: "foobar" diff --git a/tests/tasks/scratch/scratch.cue b/tests/tasks/scratch/scratch.cue index 10bf890b..cf69b5c8 100644 --- a/tests/tasks/scratch/scratch.cue +++ b/tests/tasks/scratch/scratch.cue @@ -10,13 +10,11 @@ engine.#Plan & { source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" } - scratch: engine.#Scratch - exec: engine.#Exec & { input: image.output mounts: fs: { dest: "/scratch" - contents: scratch.output + contents: engine.#Scratch } workdir: "/" args: [