Merge pull request #529 from grouville/dagger_compute-out_of_bound

dagger compute out-of-bound
This commit is contained in:
Andrea Luzzardi 2021-06-01 13:29:34 -07:00 committed by GitHub
commit 413dec63a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -43,6 +43,10 @@ var computeCmd = &cobra.Command{
for _, input := range viper.GetStringSlice("input-string") {
parts := strings.SplitN(input, "=", 2)
if len(parts) != 2 {
lg.Fatal().Msgf("failed to parse input: input-string")
}
k, v := parts[0], parts[1]
err := st.SetInput(k, state.TextInput(v))
if err != nil {
@ -56,6 +60,10 @@ var computeCmd = &cobra.Command{
for _, input := range viper.GetStringSlice("input-dir") {
parts := strings.SplitN(input, "=", 2)
if len(parts) != 2 {
lg.Fatal().Msgf("failed to parse input: input-dir")
}
k, v := parts[0], parts[1]
err := st.SetInput(k, state.DirInput(v, []string{}, []string{}))
if err != nil {
@ -69,6 +77,10 @@ var computeCmd = &cobra.Command{
for _, input := range viper.GetStringSlice("input-git") {
parts := strings.SplitN(input, "=", 2)
if len(parts) != 2 {
lg.Fatal().Msgf("failed to parse input: input-git")
}
k, v := parts[0], parts[1]
err := st.SetInput(k, state.GitInput(v, "", ""))
if err != nil {

View File

@ -65,6 +65,18 @@ setup() {
run "$DAGGER" compute --input-string 'in=foobar' "$TESTDIR"/compute/input/default
assert_success
assert_line '{"in":"foobar","test":"received: foobar"}'
run "$DAGGER" compute --input-string=foobar "$TESTDIR"/compute/input/default
assert_failure
assert_output --partial 'failed to parse input: input-string'
run "$DAGGER" compute --input-dir=foobar "$TESTDIR"/compute/input/default
assert_failure
assert_output --partial 'failed to parse input: input-dir'
run "$DAGGER" compute --input-git=foobar "$TESTDIR"/compute/input/default
assert_failure
assert_output --partial 'failed to parse input: input-git'
}
@test "compute: secrets" {