From 6f4577d501d6be13852447ad9514535ca9a7fb8f Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Tue, 26 Jan 2021 16:37:11 -0800 Subject: [PATCH] Fix and improve examples/simple Signed-off-by: Solomon Hykes --- Makefile | 3 +++ .../pkg/dagger.cloud/dagger/dagger.cue | 25 +++++++++---------- examples/simple/simple.cue | 25 ++++++++++++++++--- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 968da87d..4424cfad 100644 --- a/Makefile +++ b/Makefile @@ -33,3 +33,6 @@ integration: dagger-debug ./examples/tests/test-test.sh 2>/dev/null # Actual integration tests DAGGER_BINARY="./cmd/dagger/dagger-debug" time ./examples/tests/test.sh all + +update-examples: + cp ./dagger/spec.cue ./examples/simple/cue.mod/pkg/dagger.cloud/dagger/dagger.cue diff --git a/examples/simple/cue.mod/pkg/dagger.cloud/dagger/dagger.cue b/examples/simple/cue.mod/pkg/dagger.cloud/dagger/dagger.cue index bbfadfe4..407d9127 100644 --- a/examples/simple/cue.mod/pkg/dagger.cloud/dagger/dagger.cue +++ b/examples/simple/cue.mod/pkg/dagger.cloud/dagger/dagger.cue @@ -32,11 +32,15 @@ package dagger // by scripts defining how to compute it, present it to a user, // encrypt it, etc. -// FIXME: #Component will not match embedded scalars. -// use Runtime.isComponent() for a reliable check #Component: { + // Match structs #dagger: #ComponentConfig ... +} | { + // Match embedded strings + // FIXME: match all embedded scalar types + string + #dagger: #ComponentConfig } // The contents of a #dagger annotation @@ -65,7 +69,7 @@ package dagger #Local: { do: "local" dir: string - include?: [...string] | *[] + include: [...string] | *[] } // FIXME: bring back load (more efficient than copy) @@ -81,17 +85,17 @@ package dagger env?: [string]: string always?: true | *false dir: string | *"/" - mount?: [string]: #MountTmp | #MountCache | #MountComponent | #MountScript + mount: [string]: #MountTmp | #MountCache | #MountComponent | #MountScript } #MountTmp: "tmpfs" #MountCache: "cache" #MountComponent: { - input: #Component + from: #Component path: string | *"/" } #MountScript: { - input: #Script + from: #Script path: string | *"/" } @@ -107,13 +111,8 @@ package dagger } #Copy: { - do: "copy" - from: #Script | #Component + do: "copy" + from: #Script | #Component src: string | *"/" dest: string | *"/" } - -#TestScript: #Script & [ - {do: "fetch-container", ref: "alpine:latest"}, - {do: "exec", args: ["echo", "hello", "world"]}, -] diff --git a/examples/simple/simple.cue b/examples/simple/simple.cue index 229e6ce2..e096eb13 100644 --- a/examples/simple/simple.cue +++ b/examples/simple/simple.cue @@ -21,6 +21,26 @@ www: { #dagger: compute: _ } + // List the contents of the source directory + listing: { + string + + #dagger: compute: [ + dagger.#Load & { + from: base + }, + dagger.#Exec & { + args: ["sh", "-c", "ls /src > /tmp/out"] + mount: "/src": { + from: source + } + }, + dagger.#Export & { + source: "/tmp/out" + } + ] + } + host: string url: { @@ -30,12 +50,9 @@ www: { dagger.#Load & { from: base }, dagger.#Exec & { args: ["sh", "-c", "echo -n 'https://\(host)/foo' > /tmp/out"] - // https://github.com/blocklayerhq/dagger/issues/6 - mount: foo: {} }, dagger.#Export & { - // https://github.com/blocklayerhq/dagger/issues/8 - // source: "/tmp/out" + source: "/tmp/out" }, ] }