Initial pass at engine.#Scratch
- failing
Signed-off-by: Joel Longtine <joel@dagger.io>
This commit is contained in:
parent
262020d709
commit
75d5ab8f01
31
plan/task/scratch.go
Normal file
31
plan/task/scratch.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package task
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/moby/buildkit/client/llb"
|
||||||
|
"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) {
|
||||||
|
st := llb.Scratch()
|
||||||
|
result, err := s.Solve(ctx, st, pctx.Platform.Get())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
fs := pctx.FS.New(result)
|
||||||
|
|
||||||
|
return compiler.NewValue().FillFields(map[string]interface{}{
|
||||||
|
"output": fs.MarshalCUE(),
|
||||||
|
})
|
||||||
|
}
|
@ -88,3 +88,8 @@ setup() {
|
|||||||
|
|
||||||
"$DAGGER" --europa up ./build_auth.cue
|
"$DAGGER" --europa up ./build_auth.cue
|
||||||
}
|
}
|
||||||
|
@test "task: #Scratch" {
|
||||||
|
cd "$TESTDIR"/tasks/scratch
|
||||||
|
"$DAGGER" --europa up ./scratch.cue -l debug
|
||||||
|
}
|
||||||
|
|
||||||
|
1
tests/tasks/scratch/cue.mod/module.cue
Normal file
1
tests/tasks/scratch/cue.mod/module.cue
Normal file
@ -0,0 +1 @@
|
|||||||
|
module: ""
|
3
tests/tasks/scratch/cue.mod/pkg/.gitignore
vendored
Normal file
3
tests/tasks/scratch/cue.mod/pkg/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# generated by dagger
|
||||||
|
alpha.dagger.io
|
||||||
|
dagger.lock
|
31
tests/tasks/scratch/scratch.cue
Normal file
31
tests/tasks/scratch/scratch.cue
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"alpha.dagger.io/europa/dagger/engine"
|
||||||
|
)
|
||||||
|
|
||||||
|
engine.#Plan & {
|
||||||
|
actions: {
|
||||||
|
image: engine.#Pull & {
|
||||||
|
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
|
||||||
|
}
|
||||||
|
|
||||||
|
scratch: engine.#Scratch
|
||||||
|
|
||||||
|
exec: engine.#Exec & {
|
||||||
|
input: image.output
|
||||||
|
mounts: fs: {
|
||||||
|
dest: "/scratch"
|
||||||
|
contents: scratch.output
|
||||||
|
}
|
||||||
|
workdir: "/"
|
||||||
|
args: [
|
||||||
|
"sh", "-c",
|
||||||
|
#"""
|
||||||
|
ls -al
|
||||||
|
"""#,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user