dagger do action options flags

Signed-off-by: Joel Longtine <joel@dagger.io>
This commit is contained in:
Joel Longtine
2022-03-28 13:47:42 -06:00
parent 069227e30c
commit dae0ee1d1e
10 changed files with 341 additions and 46 deletions

View File

@@ -52,6 +52,14 @@ setup() {
assert_output --partial ": running \`dagger project update\` may resolve this"
}
@test "plan/do: check flags" {
run "$DAGGER" "do" -p ./plan/do/do_flags.cue test --help
assert_output --partial "--doit"
assert_output --partial "--message string"
assert_output --partial "--name string"
assert_output --partial "--num float"
}
@test "plan/hello" {
# Europa loader handles the cwd differently, therefore we need to CD into the tree at or below the parent of cue.mod
cd "$TESTDIR"
@@ -264,7 +272,7 @@ setup() {
# ip address is in a reserved range that should be unroutable
export BUILDKIT_HOST=tcp://192.0.2.1:1234
run timeout 30 "$DAGGER" "do" -p ./plan/do/actions.cue test
run timeout 30 "$DAGGER" "do" -p ./plan/do/actions.cue frontend test
assert_failure
assert_output --partial "Unavailable: connection error"
}

View File

@@ -0,0 +1,61 @@
package flags
import (
"dagger.io/dagger"
"universe.dagger.io/alpine"
"universe.dagger.io/bash"
)
dagger.#Plan & {
client: filesystem: "./test_do": write: contents: actions.test.one.export.files["/output.txt"]
actions: {
foo: "bar"
// Pull alpine image
image: alpine.#Build & {
packages: bash: {}
}
// Run test
test: {
// Which name?
name: string | *"World"
// What message?
message: string
// How many?
num: float
// on or off?
doit: bool | *true
// this is foo2
foo2: foo
// do the first thing
one: bash.#Run & {
input: image.output
script: contents: "echo Hello \(name)! \(doit) > /output.txt"
export: files: "/output.txt": string
}
// Do the second thing
two: bash.#Run & {
input: image.output
script: contents: "true"
}
// Do the third thing
three: bash.#Run & {
input: image.output
script: contents: "cat /one/output.txt"
mounts: output: {
contents: one.export.rootfs
dest: "/one"
}
}
}
// !!! DON'T RUN ME !!!
notMe: bash.#Run & {
input: image.output
script: contents: "false"
}
}
}

View File

@@ -11,7 +11,7 @@ setup() {
}
@test "task: #Push" {
"$DAGGER" "do" -p ./tasks/push/push.cue pullContent
"$DAGGER" "do" -p ./tasks/push/push.cue pullOutputFile
}
@test "task: #ReadFile" {