engine: Make paths relative to the CUE file they're defined in

Fixes #1309

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-12-23 19:09:26 +01:00
committed by Sam Alba
parent ec69734c51
commit 9c81a155c9
12 changed files with 134 additions and 30 deletions

View File

@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
"strings"
"time"
@@ -97,16 +96,12 @@ func (p *Plan) registerLocalDirs() error {
}
for _, v := range imports {
dir, err := v.Value.Lookup("path").String()
dir, err := v.Value.Lookup("path").AbsPath()
if err != nil {
return err
}
abs, err := filepath.Abs(dir)
if err != nil {
return err
}
if _, err := os.Stat(abs); errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("path %q does not exist", abs)
if _, err := os.Stat(dir); errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("path %q does not exist", dir)
}
p.context.LocalDirs.Add(dir)
}