implements dagger do

Signed-off-by: Richard Jones <richard@dagger.io>
This commit is contained in:
Richard Jones
2022-02-22 14:04:54 -07:00
parent 621edd6b2f
commit 6cdf13223c
23 changed files with 486 additions and 335 deletions

View File

@@ -1,15 +0,0 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
inputs: directories: test: path: "."
actions: verify: dagger.#ReadFile & {
input: inputs.directories.test.contents
path: "test.txt"
} & {
contents: "local dfsadf" // should fail with conflicting values
}
}

View File

@@ -1,15 +0,0 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
inputs: directories: test: path: "."
actions: verify: dagger.#ReadFile & {
input: inputs.directories.test.contents
path: "test.txt"
} & {
contents: "local directory"
}
}

View File

@@ -0,0 +1,3 @@
package main
inputs: directories: test: path: "./fasdfsdfs"

View File

@@ -0,0 +1,31 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
inputs: directories: test: path: string
actions: {
_readFile: dagger.#ReadFile & {
input: inputs.directories.test.contents
path: "test.txt"
}
// Test that file exists and contains correct content
exists: _readFile & {
contents: "local directory"
}
// Test that file does NOT exist
notExists: _readFile & {
contents: "local directory"
}
// Test that file exists and contains conflicting content
conflictingValues: _readFile & {
contents: "local dfsadf"
}
}
}

View File

@@ -1,16 +0,0 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
// should fail because path does not exist locally
inputs: directories: test: path: "./fasdfsdfs"
actions: verify: dagger.#ReadFile & {
input: inputs.directories.test.contents
path: "test.txt"
} & {
contents: "local directory"
}
}

View File

@@ -0,0 +1,3 @@
package main
inputs: directories: test: path: "."

View File

@@ -1,34 +0,0 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
inputs: secrets: echo: command: {
name: "echo"
args: ["hello europa"]
}
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
verify: dagger.#Exec & {
input: image.output
mounts: secret: {
dest: "/run/secrets/test"
contents: inputs.secrets.echo.contents
}
args: [
"sh", "-c",
#"""
test "$(cat /run/secrets/test)" = "hello europa"
ls -l /run/secrets/test | grep -- "-r--------"
"""#,
]
}
}
}

View File

@@ -1,33 +0,0 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
inputs: secrets: echo: command: {
name: "cat"
args: ["./test.txt"]
}
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
verify: dagger.#Exec & {
input: image.output
mounts: secret: {
dest: "/run/secrets/test"
contents: inputs.secrets.echo.contents
}
args: [
"sh", "-c",
#"""
test "$(cat /run/secrets/test)" = "test"
"""#,
]
}
}
}

View File

@@ -1,34 +0,0 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
inputs: secrets: echo: command: {
name: "rtyet" // should fail because command doesn't exist
args: ["hello europa"]
}
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
verify: dagger.#Exec & {
input: image.output
mounts: secret: {
dest: "/run/secrets/test"
contents: inputs.secrets.echo.contents
}
args: [
"sh", "-c",
#"""
test "$(cat /run/secrets/test)" = "hello europa"
ls -l /run/secrets/test | grep -- "-r--------"
"""#,
]
}
}
}

View File

@@ -1,33 +0,0 @@
package main
import (
)
dagger.#Plan & {
inputs: secrets: echo: command: {
name: "cat"
args: ["--sfgjkhf"] // // should fail because invalid option
}
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
verify: dagger.#Exec & {
input: image.output
mounts: secret: {
dest: "/run/secrets/test"
contents: inputs.secrets.echo.contents
}
args: [
"sh", "-c",
#"""
test "$(cat /run/secrets/test)" = "hello europa"
ls -l /run/secrets/test | grep -- "-r--------"
"""#,
]
}
}
}

View File

@@ -0,0 +1,59 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
inputs: secrets: {
echo: command: {
name: "echo"
args: ["hello europa"]
}
relative: command: {
name: "cat"
args: ["./test.txt"]
}
badCommand: command: {
name: "rtyet" // should fail because command doesn't exist
args: ["hello europa"]
}
badArgs: command: {
name: "cat"
args: ["--sfgjkhf"] // // should fail because invalid option
}
}
actions: {
_image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
test: {
[string]: dagger.#Exec & {
input: _image.output
mounts: secret: {
dest: "/run/secrets/test"
// contents: inputs.secrets.echo.contents
}
args: [
"sh", "-c",
#"""
test "$(cat /run/secrets/test)" = "hello europa"
ls -l /run/secrets/test | grep -- "-r--------"
"""#,
]
}
valid: mounts: secret: contents: inputs.secrets.echo.contents
relative: mounts: secret: contents: inputs.secrets.relative.contents
badCommand: mounts: secret: contents: inputs.secrets.badCommand.contents
badArgs: mounts: secret: contents: inputs.secrets.badArgs.contents
}
}
}

View File

@@ -1 +1 @@
test
hello europa