Merge pull request #1681 from helderco/trim-secret

Add #TrimSecret task
This commit is contained in:
Andrea Luzzardi
2022-03-08 15:51:32 -08:00
committed by GitHub
4 changed files with 92 additions and 2 deletions

View File

@@ -32,7 +32,7 @@ setup() {
@test "task: #WriteFile failure: different contents" {
cd "$TESTDIR"/tasks/writefile
run "$DAGGER" up ./writefile_failure_diff_contents.cue
assert_failure
assert_failure
}
@test "task: #Exec" {
@@ -102,7 +102,7 @@ setup() {
run "$DAGGER" up ./subdir_invalid_path.cue
assert_failure
run "$DAGGER" up ./subdir_invalid_exec.cue
assert_failure
}
@@ -134,6 +134,12 @@ setup() {
"$DAGGER" up ./newsecret.cue
}
@test "task: #TrimSecret" {
cd "$TESTDIR"/tasks/trimsecret
"$DAGGER" up ./trimsecret.cue
}
@test "task: #Source" {
cd "$TESTDIR"/tasks/source
"$DAGGER" up ./source.cue

View File

@@ -0,0 +1,42 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
generate: dagger.#Exec & {
input: image.output
args: ["sh", "-c", "echo ' test ' > /secret"]
}
load: dagger.#NewSecret & {
input: generate.output
trimSpace: false
path: "/secret"
}
trim: dagger.#TrimSecret & {
input: load.output
}
verify: dagger.#Exec & {
input: image.output
mounts: secret: {
dest: "/run/secrets/test"
contents: trim.output
}
args: [
"sh", "-c",
#"""
test "$(cat /run/secrets/test)" = "test"
"""#,
]
}
}
}