Fix index out of bound for Dagger compute inputs + add tests ["input-dir", "input-git", input-string"]
Signed-off-by: Guillaume de Rouville <guillaume.derouville@gmail.com>
This commit is contained in:
parent
5ab66cc5ef
commit
d74efa2420
@ -43,6 +43,10 @@ var computeCmd = &cobra.Command{
|
|||||||
|
|
||||||
for _, input := range viper.GetStringSlice("input-string") {
|
for _, input := range viper.GetStringSlice("input-string") {
|
||||||
parts := strings.SplitN(input, "=", 2)
|
parts := strings.SplitN(input, "=", 2)
|
||||||
|
if len(parts) != 2 {
|
||||||
|
lg.Fatal().Msgf("failed to parse input: input-string")
|
||||||
|
}
|
||||||
|
|
||||||
k, v := parts[0], parts[1]
|
k, v := parts[0], parts[1]
|
||||||
err := st.SetInput(k, state.TextInput(v))
|
err := st.SetInput(k, state.TextInput(v))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -56,6 +60,10 @@ var computeCmd = &cobra.Command{
|
|||||||
|
|
||||||
for _, input := range viper.GetStringSlice("input-dir") {
|
for _, input := range viper.GetStringSlice("input-dir") {
|
||||||
parts := strings.SplitN(input, "=", 2)
|
parts := strings.SplitN(input, "=", 2)
|
||||||
|
if len(parts) != 2 {
|
||||||
|
lg.Fatal().Msgf("failed to parse input: input-dir")
|
||||||
|
}
|
||||||
|
|
||||||
k, v := parts[0], parts[1]
|
k, v := parts[0], parts[1]
|
||||||
err := st.SetInput(k, state.DirInput(v, []string{}, []string{}))
|
err := st.SetInput(k, state.DirInput(v, []string{}, []string{}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -69,6 +77,10 @@ var computeCmd = &cobra.Command{
|
|||||||
|
|
||||||
for _, input := range viper.GetStringSlice("input-git") {
|
for _, input := range viper.GetStringSlice("input-git") {
|
||||||
parts := strings.SplitN(input, "=", 2)
|
parts := strings.SplitN(input, "=", 2)
|
||||||
|
if len(parts) != 2 {
|
||||||
|
lg.Fatal().Msgf("failed to parse input: input-git")
|
||||||
|
}
|
||||||
|
|
||||||
k, v := parts[0], parts[1]
|
k, v := parts[0], parts[1]
|
||||||
err := st.SetInput(k, state.GitInput(v, "", ""))
|
err := st.SetInput(k, state.GitInput(v, "", ""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -65,6 +65,18 @@ setup() {
|
|||||||
run "$DAGGER" compute --input-string 'in=foobar' "$TESTDIR"/compute/input/default
|
run "$DAGGER" compute --input-string 'in=foobar' "$TESTDIR"/compute/input/default
|
||||||
assert_success
|
assert_success
|
||||||
assert_line '{"in":"foobar","test":"received: foobar"}'
|
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" {
|
@test "compute: secrets" {
|
||||||
|
Reference in New Issue
Block a user