Ensure we can Marshall #Scratch as CUE
Signed-off-by: Joel Longtine <joel@dagger.io>
This commit is contained in:
parent
6a7b5f3337
commit
a3db716c0a
@ -115,14 +115,19 @@ func (t *buildTask) dockerfile(ctx context.Context, pctx *plancontext.Context, s
|
||||
return nil, err
|
||||
}
|
||||
|
||||
st, err := ref.ToState()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var solvedRef bkgw.Reference
|
||||
if ref != nil {
|
||||
st, err := ref.ToState()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
solvedRef, err := s.Solve(ctx, st, pctx.Platform.Get())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
solvedRef, err = s.Solve(ctx, st, pctx.Platform.Get())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
solvedRef = ref
|
||||
}
|
||||
|
||||
// Image metadata
|
||||
|
@ -42,8 +42,14 @@ func (fs *FS) State() (llb.State, error) {
|
||||
|
||||
func (fs *FS) MarshalCUE() *compiler.Value {
|
||||
v := compiler.NewValue()
|
||||
if err := v.FillPath(fsIDPath, fs.id); err != nil {
|
||||
panic(err)
|
||||
if fs.result == nil {
|
||||
if err := v.FillPath(fsIDPath, nil); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
if err := v.FillPath(fsIDPath, fs.id); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
@ -92,6 +92,8 @@ setup() {
|
||||
@test "task: #Scratch" {
|
||||
cd "$TESTDIR"/tasks/scratch
|
||||
"$DAGGER" --europa up ./scratch.cue -l debug
|
||||
"$DAGGER" --europa up ./scratch_build_scratch.cue -l debug
|
||||
"$DAGGER" --europa up ./scratch_writefile.cue -l debug
|
||||
}
|
||||
|
||||
@test "task: #Subdir" {
|
||||
|
25
tests/tasks/scratch/scratch_build_scratch.cue
Normal file
25
tests/tasks/scratch/scratch_build_scratch.cue
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/europa/dagger/engine"
|
||||
)
|
||||
|
||||
engine.#Plan & {
|
||||
actions: {
|
||||
write: engine.#WriteFile & {
|
||||
input: engine.#Scratch
|
||||
path: "/.dockerignore"
|
||||
contents: "Dockerfile"
|
||||
permissions: 700
|
||||
}
|
||||
|
||||
build: engine.#Build & {
|
||||
source: write.output
|
||||
dockerfile: contents: """
|
||||
FROM scratch
|
||||
"""
|
||||
// Assert that output is engine.#Scratch
|
||||
output: engine.#Scratch
|
||||
}
|
||||
}
|
||||
}
|
23
tests/tasks/scratch/scratch_writefile.cue
Normal file
23
tests/tasks/scratch/scratch_writefile.cue
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/europa/dagger/engine"
|
||||
)
|
||||
|
||||
engine.#Plan & {
|
||||
actions: {
|
||||
write: engine.#WriteFile & {
|
||||
input: engine.#Scratch
|
||||
path: "/testing"
|
||||
contents: "1,2,3"
|
||||
permissions: 700
|
||||
}
|
||||
readfile: engine.#ReadFile & {
|
||||
input: write.output
|
||||
path: "/testing"
|
||||
} & {
|
||||
// assert result
|
||||
contents: "1,2,3"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user