returning stderr
Signed-off-by: Richard Jones <richard@dagger.io>
This commit is contained in:
parent
9b4c92ad84
commit
95542d29cb
@ -2,6 +2,7 @@ package task
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -49,6 +50,10 @@ func (c *inputSecretExecTask) Run(ctx context.Context, pctx *plancontext.Context
|
|||||||
// sec audited by @aluzzardi and @mrjones
|
// sec audited by @aluzzardi and @mrjones
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
var exitErr *exec.ExitError
|
||||||
|
if errors.As(err, &exitErr) {
|
||||||
|
return nil, errors.New(string(exitErr.Stderr))
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,21 +65,18 @@ setup() {
|
|||||||
assert_output --partial 'conflicting values "local directory" and "local dfsadf"'
|
assert_output --partial 'conflicting values "local directory" and "local dfsadf"'
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plan/inputs/secrets exec" {
|
@test "plan/inputs/secrets" {
|
||||||
cd "$TESTDIR"
|
cd "$TESTDIR"
|
||||||
"$DAGGER" --europa up ./plan/inputs/secrets/exec.cue
|
"$DAGGER" --europa up ./plan/inputs/secrets/exec.cue
|
||||||
}
|
"$DAGGER" --europa up ./plan/inputs/secrets/exec_relative.cue
|
||||||
|
|
||||||
@test "plan/inputs/secrets exec relative" {
|
|
||||||
cd "$TESTDIR"
|
|
||||||
"$DAGGER" --europa up ./plan/inputs/secrets/exec.cue
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "plan/inputs/secrets invalid command" {
|
|
||||||
cd "$TESTDIR"
|
|
||||||
run "$DAGGER" --europa up ./plan/inputs/secrets/invalid_command.cue
|
run "$DAGGER" --europa up ./plan/inputs/secrets/invalid_command.cue
|
||||||
assert_failure
|
assert_failure
|
||||||
assert_output --partial 'failed: exec: "rtyet": executable file not found'
|
assert_output --partial 'failed: exec: "rtyet": executable file not found'
|
||||||
|
|
||||||
|
run "$DAGGER" --europa up ./plan/inputs/secrets/invalid_command_options.cue
|
||||||
|
assert_failure
|
||||||
|
assert_output --partial 'illegal option'
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plan/with" {
|
@test "plan/with" {
|
||||||
|
34
tests/plan/inputs/secrets/invalid_command_options.cue
Normal file
34
tests/plan/inputs/secrets/invalid_command_options.cue
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"alpha.dagger.io/europa/dagger/engine"
|
||||||
|
)
|
||||||
|
|
||||||
|
engine.#Plan & {
|
||||||
|
inputs: secrets: echo: command: {
|
||||||
|
name: "cat"
|
||||||
|
args: ["--sfgjkhf"] // // should fail because invalid option
|
||||||
|
}
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
|
||||||
|
image: engine.#Pull & {
|
||||||
|
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
|
||||||
|
}
|
||||||
|
|
||||||
|
verify: engine.#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--------"
|
||||||
|
"""#,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user