Merge pull request #973 from grouville/fix/bug-infinite-loop
fix/bug: infinite loop non-existent input dir path
This commit is contained in:
commit
8dbfdaca1b
@ -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")
|
||||
|
@ -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" {
|
||||
|
Reference in New Issue
Block a user