Merge pull request #1704 from helderco/inputs-outputs-cleanup

Inputs/outputs cleanup
This commit is contained in:
Andrea Luzzardi
2022-03-08 16:16:15 -08:00
committed by GitHub
54 changed files with 101 additions and 1083 deletions

View File

@@ -45,24 +45,24 @@ setup() {
"$DAGGER" "do" -p ./usage test valid
run "$DAGGER" "do" -p ./usage test conflictingValues
assert_failure
assert_output --partial 'conflicting values "local directory" and "local foobar"'
assert_failure
assert_output --partial 'conflicting values "local directory" and "local foobar"'
run "$DAGGER" "do" -p ./usage test excluded
assert_failure
assert_line --partial 'test.log: no such file or directory'
assert_failure
assert_line --partial 'test.log: no such file or directory'
run "$DAGGER" "do" -p ./usage test notExists
assert_failure
assert_output --partial 'test.json: no such file or directory'
assert_failure
assert_output --partial 'test.json: no such file or directory'
}
@test "plan/client/filesystem/read/fs/not_exists" {
cd "$TESTDIR/plan/client/filesystem/read/fs/not_exists"
run "$DAGGER" "do" -p . test
assert_failure
assert_output --partial 'path "/foobar" does not exist'
assert_failure
assert_output --partial 'path "/foobar" does not exist'
}
@test "plan/client/filesystem/read/fs/relative" {
@@ -71,8 +71,8 @@ setup() {
"$DAGGER" "do" -p . test valid
run "$DAGGER" "do" -p . test notIncluded
assert_failure
assert_output --partial 'test.log: no such file or directory'
assert_failure
assert_output --partial 'test.log: no such file or directory'
}
@test "plan/client/filesystem/read/file" {
@@ -171,72 +171,16 @@ setup() {
"$DAGGER" "do" -p . test valid
run "$DAGGER" "do" -p . test invalid
assert_failure
assert_output --partial 'exec: "foobar": executable file not found'
}
@test "plan/proxy invalid schema" {
cd "$TESTDIR"
run "$DAGGER" "do" -p ./plan/proxy/invalid_schema.cue verify
assert_failure
}
@test "plan/proxy invalid value" {
cd "$TESTDIR"
run "$DAGGER" "do" -p ./plan/proxy/invalid_value.cue verify
assert_failure
}
@test "plan/proxy incomplete unix" {
cd "$TESTDIR"
run "$DAGGER" "do" -p ./plan/proxy/incomplete_unix.cue verify
assert_failure
}
@test "plan/proxy incomplete service" {
cd "$TESTDIR"
run "$DAGGER" "do" -p ./plan/proxy/incomplete_service.cue verify
assert_output --partial 'mount "docker" is not concrete'
}
@test "plan/proxy unix" {
cd "$TESTDIR"
"$DAGGER" "do" -p ./plan/proxy/unix.cue verify
}
@test "plan/inputs/directories" {
cd "$TESTDIR"
"$DAGGER" "do" -p ./plan/inputs/directories/valid exists
run "$DAGGER" "do" -p ./plan/inputs/directories/invalid notExists
assert_failure
assert_output --partial 'fasdfsdfs" does not exist'
run "$DAGGER" "do" -p ./plan/inputs/directories/valid conflictingValues
assert_failure
assert_output --partial 'conflicting values "local directory" and "local dfsadf"'
}
@test "plan/inputs/secrets" {
cd "$TESTDIR"
"$DAGGER" "do" -p ./plan/inputs/secrets test valid
"$DAGGER" "do" -p ./plan/inputs/secrets test relative
run "$DAGGER" "do" -p ./plan/inputs/secrets test badCommand
assert_failure
assert_output --partial 'failed: exec: "rtyet": executable file not found'
run "$DAGGER" "do" -p ./plan/inputs/secrets test badArgs
assert_failure
assert_output --partial 'option'
assert_output --partial 'exec: "foobar": executable file not found'
}
@test "plan/with" {
cd "$TESTDIR"
"$DAGGER" "do" --with 'inputs: params: foo:"bar"' -p ./plan/with test params
"$DAGGER" "do" --with 'actions: params: foo:"bar"' -p ./plan/with test params
"$DAGGER" "do" --with 'actions: test: direct: env: FOO: "bar"' -p ./plan/with test direct
run "$DAGGER" "do" --with 'inputs: params: foo:1' -p ./plan/with test params
run "$DAGGER" "do" --with 'actions: params: foo:1' -p ./plan/with test params
assert_failure
assert_output --partial "conflicting values string and 1"

View File

@@ -31,11 +31,6 @@ dagger.#Plan & {
input: write.output
path: "out.txt"
}
// FIXME: hack until we can do outputs with `dagger do`
verify: dagger.#Exec & {
input: image.output
args: ["echo", client.filesystem."test.txt".write.contents]
}
}
}
}

View File

@@ -19,17 +19,10 @@ dagger.#Plan & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
test: {
fs: {
data: dagger.#WriteFile & {
input: dagger.#Scratch
path: "/test"
contents: "foobar"
}
// FIXME: hack until we can do outputs with `dagger do`
verify: dagger.#ReadFile & {
input: client.filesystem."out_fs".write.contents
path: "test"
}
fs: data: dagger.#WriteFile & {
input: dagger.#Scratch
path: "/test"
contents: "foobar"
}
file: {
// Only using contents for reference in client
@@ -38,11 +31,6 @@ dagger.#Plan & {
path: "/test"
contents: "foobaz"
}
// FIXME: hack until we can do outputs with `dagger do`
verify: dagger.#Exec & {
input: image.output
args: ["echo", "-c", client.filesystem."out_files/test.txt".write.contents]
}
}
secret: {
create: dagger.#WriteFile & {
@@ -54,15 +42,6 @@ dagger.#Plan & {
input: create.output
path: "/test"
}
// FIXME: hack until we can do outputs with `dagger do`
verify: dagger.#Exec & {
input: image.output
mounts: secret: {
dest: "/run/secrets/test"
contents: client.filesystem."out_files/secret.txt".write.contents
}
args: ["id"]
}
}
}
}

View File

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

View File

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

View File

@@ -1 +0,0 @@
local directory

View File

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

View File

@@ -1,59 +0,0 @@
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 +0,0 @@
hello europa

View File

@@ -1 +0,0 @@
out

View File

@@ -1,19 +0,0 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
actions: data: dagger.#WriteFile & {
input: dagger.#Scratch
path: "/test_outputs"
permissions: 0o600
contents: "foobar"
}
outputs: directories: test_outputs: {
contents: actions.data.output
dest: "./out"
}
}

View File

@@ -1,19 +0,0 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
actions: data: dagger.#WriteFile & {
input: dagger.#Scratch
path: "/test_relative"
permissions: 0o600
contents: "foobar"
}
outputs: directories: test_relative: {
contents: actions.data.output
dest: "./out"
}
}

View File

@@ -1,10 +0,0 @@
package main
import "dagger.io/dagger"
dagger.#Plan & {
outputs: files: test: {
contents: "foobar"
dest: "./test_default_permissions"
}
}

View File

@@ -1,7 +0,0 @@
package main
import "dagger.io/dagger"
dagger.#Plan & {
outputs: files: test: dest: "./test_no_contents"
}

View File

@@ -1,15 +0,0 @@
package main
import "dagger.io/dagger"
dagger.#Plan & {
outputs: files: {
[path=string]: dest: path
test_relative: contents: """
#!/bin/bash
set -euo pipefail
echo "Hello World!"
"""
}
}

View File

@@ -1,18 +0,0 @@
package main
import "dagger.io/dagger"
dagger.#Plan & {
outputs: files: {
[path=string]: dest: path
test_usage: {
contents: """
#!/bin/bash
set -euo pipefail
echo "Hello World!"
"""
permissions: 0o750
}
}
}

View File

@@ -1,32 +0,0 @@
package main
import (
"dagger.io/dagger"
// "alpha.dagger.io/dagger/op"
// "alpha.dagger.io/alpine"
)
dagger.#Plan & {
// should fail due to incomplete service
proxy: dockerSocket: {}
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
imageWithDocker: dagger.#Exec & {
input: image.output
args: ["apk", "add", "--no-cache", "docker-cli"]
}
verify: dagger.#Exec & {
input: imageWithDocker.output
mounts: docker: {
dest: "/var/run/docker.sock"
contents: proxy.dockerSocket.service
}
args: ["docker", "info"]
}
}
}

View File

@@ -1,32 +0,0 @@
package main
import (
"dagger.io/dagger"
// "alpha.dagger.io/dagger/op"
// "alpha.dagger.io/alpine"
)
dagger.#Plan & {
// should fail because incomplete value
proxy: dockerSocket: unix: string
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
imageWithDocker: dagger.#Exec & {
input: image.output
args: ["apk", "add", "--no-cache", "docker-cli"]
}
verify: dagger.#Exec & {
input: imageWithDocker.output
mounts: docker: {
dest: "/var/run/docker.sock"
contents: proxy.dockerSocket.service
}
args: ["docker", "info"]
}
}
}

View File

@@ -1,32 +0,0 @@
package main
import (
"dagger.io/dagger"
// "alpha.dagger.io/dagger/op"
// "alpha.dagger.io/alpine"
)
dagger.#Plan & {
// should fail because of misspelled key
proxy: dockerSocket: unx: "/var/run/docker.sock"
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
imageWithDocker: dagger.#Exec & {
input: image.output
args: ["apk", "add", "--no-cache", "docker-cli"]
}
verify: dagger.#Exec & {
input: imageWithDocker.output
mounts: docker: {
dest: "/var/run/docker.sock"
contents: proxy.dockerSocket.service
}
args: ["docker", "info"]
}
}
}

View File

@@ -1,32 +0,0 @@
package main
import (
"dagger.io/dagger"
// "alpha.dagger.io/dagger/op"
// "alpha.dagger.io/alpine"
)
dagger.#Plan & {
// should fail because of misspelled value
proxy: dockerSocket: unix: "/var/run/docker.soc"
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
imageWithDocker: dagger.#Exec & {
input: image.output
args: ["apk", "add", "--no-cache", "docker-cli"]
}
verify: dagger.#Exec & {
input: imageWithDocker.output
mounts: docker: {
dest: "/var/run/docker.sock"
contents: proxy.dockerSocket.service
}
args: ["docker", "info"]
}
}
}

View File

@@ -1,32 +0,0 @@
package main
import (
"dagger.io/dagger"
// "alpha.dagger.io/dagger/op"
// "alpha.dagger.io/alpine"
)
dagger.#Plan & {
// should succeed
proxy: dockerSocket: unix: "/var/run/docker.sock"
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
imageWithDocker: dagger.#Exec & {
input: image.output
args: ["apk", "add", "--no-cache", "docker-cli"]
}
verify: dagger.#Exec & {
input: imageWithDocker.output
mounts: docker: {
dest: "/var/run/docker.sock"
contents: proxy.dockerSocket.service
}
args: ["docker", "info"]
}
}
}

View File

@@ -5,9 +5,9 @@ import (
)
dagger.#Plan & {
inputs: params: foo: string
actions: {
params: foo: string
_image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
@@ -25,7 +25,7 @@ dagger.#Plan & {
}
direct: {}
params: env: FOO: inputs.params.foo
"params": env: FOO: params.foo
}
}
}

View File

@@ -5,10 +5,10 @@ import (
)
dagger.#Plan & {
inputs: directories: testdata: path: "./testdata"
client: filesystem: testdata: read: contents: dagger.#FS
actions: build: dagger.#Dockerfile & {
source: inputs.directories.testdata.contents
source: client.filesystem.testdata.read.contents
dockerfile: contents: """
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
ARG TEST=foo

View File

@@ -5,22 +5,23 @@ import (
)
dagger.#Plan & {
inputs: {
directories: testdata: path: "./testdata"
secrets: sops: command: {
client: {
filesystem: testdata: read: contents: dagger.#FS
commands: sops: {
name: "sops"
args: ["-d", "../../secrets_sops.yaml"]
stdout: dagger.#Secret
}
}
actions: {
sopsSecrets: dagger.#DecodeSecret & {
format: "yaml"
input: inputs.secrets.sops.contents
input: client.commands.sops.stdout
}
build: dagger.#Dockerfile & {
source: inputs.directories.testdata.contents
source: client.filesystem.testdata.read.contents
auth: "daggerio/ci-test:private-pull": {
username: "daggertest"
secret: sopsSecrets.output.DOCKERHUB_TOKEN.contents

View File

@@ -5,11 +5,11 @@ import (
)
dagger.#Plan & {
inputs: directories: testdata: path: "./testdata"
client: filesystem: testdata: read: contents: dagger.#FS
actions: {
build: dagger.#Dockerfile & {
source: inputs.directories.testdata.contents
source: client.filesystem.testdata.read.contents
}
verify: dagger.#Exec & {

View File

@@ -5,11 +5,11 @@ import (
)
dagger.#Plan & {
inputs: directories: testdata: path: "./testdata"
client: filesystem: testdata: read: contents: dagger.#FS
actions: {
build: dagger.#Dockerfile & {
source: inputs.directories.testdata.contents
source: client.filesystem.testdata.read.contents
dockerfile: path: "./dockerfilepath/Dockerfile.custom"
}

View File

@@ -5,12 +5,12 @@ import (
)
dagger.#Plan & {
inputs: directories: testdata: path: "./testdata"
client: filesystem: testdata: read: contents: dagger.#FS
actions: {
// FIXME: this doesn't test anything beside not crashing
build: dagger.#Dockerfile & {
source: inputs.directories.testdata.contents
source: client.filesystem.testdata.read.contents
dockerfile: contents: """
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
ENV test foobar

View File

@@ -5,11 +5,11 @@ import (
)
dagger.#Plan & {
inputs: directories: testdata: path: "./testdata"
client: filesystem: testdata: read: contents: dagger.#FS
actions: {
build: dagger.#Dockerfile & {
source: inputs.directories.testdata.contents
source: client.filesystem.testdata.read.contents
dockerfile: contents: """
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
RUN echo foobar > /output

View File

@@ -5,11 +5,11 @@ import (
)
dagger.#Plan & {
inputs: directories: testdata: path: "./testdata"
client: filesystem: testdata: read: contents: dagger.#FS
actions: {
build: dagger.#Dockerfile & {
source: inputs.directories.testdata.contents
source: client.filesystem.testdata.read.contents
dockerfile: contents: """
# syntax = docker/dockerfile:1.3
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d

View File

@@ -5,12 +5,12 @@ import (
)
dagger.#Plan & {
inputs: directories: testdata: path: "./testdata"
client: filesystem: testdata: read: contents: dagger.#FS
actions: {
// FIXME: this doesn't test anything beside not crashing
build: dagger.#Dockerfile & {
source: inputs.directories.testdata.contents
source: client.filesystem.testdata.read.contents
dockerfile: contents: """
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
"""

View File

@@ -5,12 +5,12 @@ import (
)
dagger.#Plan & {
inputs: directories: testdata: path: "./testdata"
client: filesystem: testdata: read: contents: dagger.#FS
actions: {
// FIXME: this doesn't test anything beside not crashing
build: dagger.#Dockerfile & {
source: inputs.directories.testdata.contents
source: client.filesystem.testdata.read.contents
dockerfile: contents: """
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
"""

View File

@@ -5,7 +5,7 @@ import (
)
dagger.#Plan & {
inputs: secrets: testSecret: path: "secret.txt"
client: filesystem: "secret.txt": read: contents: dagger.#Secret
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
@@ -13,7 +13,7 @@ dagger.#Plan & {
verify: dagger.#Exec & {
input: image.output
env: TEST: inputs.secrets.testSecret.contents
env: TEST: client.filesystem."secret.txt".read.contents
args: [
"sh", "-c",
#"""

View File

@@ -5,7 +5,7 @@ import (
)
dagger.#Plan & {
inputs: secrets: testSecret: envvar: "TESTSECRET"
client: env: TESTSECRET: dagger.#Secret
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
@@ -15,7 +15,7 @@ dagger.#Plan & {
input: image.output
mounts: secret: {
dest: "/run/secrets/test"
contents: inputs.secrets.testSecret.contents
contents: client.env.TESTSECRET
}
args: [
"sh", "-c",
@@ -30,7 +30,7 @@ dagger.#Plan & {
input: image.output
mounts: secret: {
dest: "/run/secrets/test"
contents: inputs.secrets.testSecret.contents
contents: client.env.TESTSECRET
uid: 42
gid: 24
mask: 0o666

View File

@@ -5,7 +5,7 @@ import (
)
dagger.#Plan & {
proxy: dockerSocket: unix: "/var/run/docker.sock"
client: filesystem: "/var/run/docker.sock": read: contents: dagger.#Service
actions: {
image: dagger.#Pull & {
@@ -21,7 +21,7 @@ dagger.#Plan & {
input: imageWithDocker.output
mounts: docker: {
dest: "/var/run/docker.sock"
contents: proxy.dockerSocket.service
contents: client.filesystem."/var/run/docker.sock".read.contents
}
args: ["docker", "info"]
}

View File

@@ -5,9 +5,10 @@ import (
)
dagger.#Plan & {
inputs: secrets: sops: command: {
client: commands: sops: {
name: "sops"
args: ["-d", "../../secrets_sops.yaml"]
args: ["-d", "secrets_sops.yaml"]
stdout: dagger.#Secret
}
actions: {
@@ -18,7 +19,7 @@ dagger.#Plan & {
sopsSecrets: dagger.#DecodeSecret & {
format: "yaml"
input: inputs.secrets.sops.contents
input: client.commands.sops.stdout
}
testRepo: dagger.#GitPull & {

View File

@@ -5,15 +5,16 @@ import (
)
dagger.#Plan & {
inputs: secrets: sops: command: {
client: commands: sops: {
name: "sops"
args: ["-d", "../../secrets_sops.yaml"]
args: ["-d", "secrets_sops.yaml"]
stdout: dagger.#Secret
}
actions: {
sopsSecrets: dagger.#DecodeSecret & {
format: "yaml"
input: inputs.secrets.sops.contents
input: client.commands.sops.stdout
}
pull: dagger.#Pull & {

View File

@@ -6,9 +6,10 @@ import (
)
dagger.#Plan & {
inputs: secrets: sops: command: {
client: commands: sops: {
name: "sops"
args: ["-d", "../../secrets_sops.yaml"]
args: ["-d", "secrets_sops.yaml"]
stdout: dagger.#Secret
}
#auth: {
@@ -17,10 +18,9 @@ dagger.#Plan & {
}
actions: {
sopsSecrets: dagger.#DecodeSecret & {
format: "yaml"
input: inputs.secrets.sops.contents
input: client.commands.sops.stdout
}
randomString: {