moved abs path to DirInput

Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
Sam Alba 2021-04-02 17:26:19 -07:00
parent 21e0ac21de
commit ce6ce871ab

View File

@ -66,6 +66,12 @@ func (i Input) Compile() (*compiler.Value, error) {
// An input artifact loaded from a local directory
func DirInput(path string, include []string) Input {
// resolve absolute path
path, err := filepath.Abs(path)
if err != nil {
panic(err)
}
return Input{
Type: InputTypeDir,
Dir: &dirInput{
@ -83,13 +89,6 @@ type dirInput struct {
func (dir dirInput) Compile() (*compiler.Value, error) {
// FIXME: serialize an intermediate struct, instead of generating cue source
// resolve absolute path
path, err := filepath.Abs(dir.Path)
if err != nil {
return nil, err
}
dir.Path = path
// json.Marshal([]string{}) returns []byte("null"), which wreaks havoc
// in Cue because `null` is not a `[...string]`
includeLLB := []byte("[]")