fix/bug: infinite loop non-existent input dir path
Signed-off-by: Guillaume de Rouville <guillaume.derouville@gmail.com>
This commit is contained in:
parent
4d45e269e0
commit
0273fead4d
@ -1,6 +1,7 @@
|
|||||||
package input
|
package input
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -31,6 +32,11 @@ var dirCmd = &cobra.Command{
|
|||||||
lg.Fatal().Err(err).Str("path", args[1]).Msg("unable to resolve path")
|
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)
|
workspace := common.CurrentWorkspace(ctx)
|
||||||
if !strings.HasPrefix(p, workspace.Path) {
|
if !strings.HasPrefix(p, workspace.Path) {
|
||||||
lg.Fatal().Err(err).Str("path", args[1]).Msg("dir is outside the workspace")
|
lg.Fatal().Err(err).Str("path", args[1]).Msg("dir is outside the workspace")
|
||||||
|
@ -317,6 +317,10 @@ setup() {
|
|||||||
assert_output '{
|
assert_output '{
|
||||||
"foo": "bar"
|
"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" {
|
@test "dagger input dir: ignore .dagger" {
|
||||||
|
Reference in New Issue
Block a user