commit
fc106e9a91
@ -24,7 +24,7 @@ func (t *copyTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
inputState, err := input.Result().ToState()
|
||||
inputState, err := input.State()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -34,7 +34,7 @@ func (t *copyTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sourceState, err := sourceRoot.Result().ToState()
|
||||
sourceState, err := sourceRoot.State()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ func (t execTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.S
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
st, err := input.Result().ToState()
|
||||
st, err := input.State()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -246,7 +246,7 @@ func (t *execTask) mountFS(pctx *plancontext.Context, dest string, mnt *compiler
|
||||
}
|
||||
}
|
||||
|
||||
st, err := contents.Result().ToState()
|
||||
st, err := contents.State()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
24
plan/task/scratch.go
Normal file
24
plan/task/scratch.go
Normal file
@ -0,0 +1,24 @@
|
||||
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(),
|
||||
})
|
||||
}
|
@ -60,7 +60,7 @@ func (t *writeFileTask) Run(ctx context.Context, pctx *plancontext.Context, s so
|
||||
return nil, err
|
||||
}
|
||||
|
||||
inputState, err := input.Result().ToState()
|
||||
inputState, err := input.State()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"cuelang.org/go/cue"
|
||||
"github.com/google/uuid"
|
||||
"github.com/moby/buildkit/client/llb"
|
||||
bkgw "github.com/moby/buildkit/frontend/gateway/client"
|
||||
"go.dagger.io/dagger/compiler"
|
||||
"go.dagger.io/dagger/stdlib"
|
||||
@ -32,6 +33,17 @@ func (fs *FS) Result() bkgw.Reference {
|
||||
return fs.result
|
||||
}
|
||||
|
||||
// func (fs *FS) FS() *solver.BuildkitFS {
|
||||
// return solver.NewBuildkitFS(fs.result)
|
||||
// }
|
||||
|
||||
func (fs *FS) State() (llb.State, error) {
|
||||
if fs.Result() == nil {
|
||||
return llb.State{}, nil
|
||||
}
|
||||
return fs.Result().ToState()
|
||||
}
|
||||
|
||||
func (fs *FS) MarshalCUE() *compiler.Value {
|
||||
v := compiler.NewValue()
|
||||
if err := v.FillPath(fsIDPath, fs.id); err != nil {
|
||||
|
@ -88,3 +88,8 @@ setup() {
|
||||
|
||||
"$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",
|
||||
#"""
|
||||
test "$(ls -A /)" != ""
|
||||
test "$(ls -A /scratch)" = ""
|
||||
"""#,
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user