fix/bug: infinite loop non-existent input dir path

Signed-off-by: Guillaume de Rouville <guillaume.derouville@gmail.com>
This commit is contained in:
Guillaume de Rouville 2021-09-14 16:17:05 +02:00
parent 4d45e269e0
commit 0273fead4d
2 changed files with 10 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package input
import (
"os"
"path/filepath"
"strings"
@ -31,6 +32,11 @@ var dirCmd = &cobra.Command{
lg.Fatal().Err(err).Str("path", args[1]).Msg("unable to resolve path")
}
// Check that directory exists
if _, err := os.Stat(p); os.IsNotExist(err) {
lg.Fatal().Err(err).Str("path", args[1]).Msg("dir doesn't exists")
}
workspace := common.CurrentWorkspace(ctx)
if !strings.HasPrefix(p, workspace.Path) {
lg.Fatal().Err(err).Str("path", args[1]).Msg("dir is outside the workspace")

View File

@ -317,6 +317,10 @@ setup() {
assert_output '{
"foo": "bar"
}'
run "$DAGGER" input dir src xxx -e "input"
assert_failure
assert_output --partial "dir doesn't exists"
}
@test "dagger input dir: ignore .dagger" {