diff --git a/dagger/script.go b/dagger/script.go index 03b6ce11..83e64542 100644 --- a/dagger/script.go +++ b/dagger/script.go @@ -4,6 +4,11 @@ import ( "context" "github.com/pkg/errors" + "github.com/rs/zerolog/log" +) + +var ( + ErrAbortExecution = errors.New("execution stopped") ) type Script struct { @@ -25,8 +30,13 @@ func (s *Script) Execute(ctx context.Context, fs FS, out Fillable) (FS, error) { // If op not concrete, interrupt without error. // This allows gradual resolution: // compute what you can compute.. leave the rest incomplete. - if !v.IsConcreteR() { - return nil + if err := v.IsConcreteR(); err != nil { + log. + Ctx(ctx). + Warn(). + Err(err). + Msg("script is unspecified, aborting execution") + return ErrAbortExecution } op, err := v.Op() if err != nil { @@ -38,6 +48,11 @@ func (s *Script) Execute(ctx context.Context, fs FS, out Fillable) (FS, error) { } return nil }) + + // If the execution was gracefully stopped, do not return an error + if err == ErrAbortExecution { + return fs, nil + } return fs, err } diff --git a/dagger/value.go b/dagger/value.go index 623ce007..496c82ef 100644 --- a/dagger/value.go +++ b/dagger/value.go @@ -167,30 +167,8 @@ func (v *Value) MergeTarget(x interface{}, target string) (*Value, error) { } // Recursive concreteness check. -// Return false if v is not concrete, or contains any -// non-concrete fields or items. -func (v *Value) IsConcreteR() bool { - // FIXME: use Value.Walk - if it, err := v.Fields(); err == nil { - for it.Next() { - w := v.Wrap(it.Value()) - if !w.IsConcreteR() { - return false - } - } - return true - } - if it, err := v.List(); err == nil { - for it.Next() { - w := v.Wrap(it.Value()) - if !w.IsConcreteR() { - return false - } - } - return true - } - dv, _ := v.val.Default() - return v.val.IsConcrete() || dv.IsConcrete() +func (v *Value) IsConcreteR() error { + return v.val.Validate(cue.Concrete(true)) } // Export concrete values to JSON. ignoring non-concrete values.