cli: moved abs path resolve to input.go
Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
parent
e6b0ca5109
commit
a799dd05d7
@ -1,8 +1,6 @@
|
||||
package input
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"dagger.io/go/cmd/dagger/logger"
|
||||
"dagger.io/go/dagger"
|
||||
"github.com/spf13/cobra"
|
||||
@ -24,12 +22,7 @@ var dirCmd = &cobra.Command{
|
||||
lg := logger.New()
|
||||
ctx := lg.WithContext(cmd.Context())
|
||||
|
||||
path, err := filepath.Abs(args[1])
|
||||
if err != nil {
|
||||
lg.Error().Err(err).Str("path", args[1]).Msg("cannot get absolute path")
|
||||
}
|
||||
|
||||
updateDeploymentInput(ctx, args[0], dagger.DirInput(path, []string{}))
|
||||
updateDeploymentInput(ctx, args[0], dagger.DirInput(args[1], []string{}))
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -103,11 +103,7 @@ func getPlanSource(ctx context.Context) dagger.Input {
|
||||
if planDir != "" {
|
||||
checkFirstSet()
|
||||
|
||||
path, err := filepath.Abs(planDir)
|
||||
if err != nil {
|
||||
lg.Error().Err(err).Str("path", planDir).Msg("cannot get absolute path")
|
||||
}
|
||||
src = dagger.DirInput(path, []string{"*.cue", "cue.mod"})
|
||||
src = dagger.DirInput(planDir, []string{"*.cue", "cue.mod"})
|
||||
}
|
||||
|
||||
if planGit != "" {
|
||||
|
@ -3,6 +3,7 @@ package dagger
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"dagger.io/go/dagger/compiler"
|
||||
)
|
||||
@ -82,6 +83,13 @@ 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("[]")
|
||||
|
Reference in New Issue
Block a user