Replace Fillable interface with a concrete wrapper

Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
Solomon Hykes
2021-01-21 16:49:25 -08:00
parent 2ee27e83f3
commit eab6028b70
6 changed files with 35 additions and 29 deletions

View File

@@ -2,25 +2,31 @@ package dagger
import (
"context"
cueflow "cuelang.org/go/tools/flow"
)
// Implemented by Component, Script, Op
type Executable interface {
Execute(context.Context, FS, Fillable) (FS, error)
Execute(context.Context, FS, *Fillable) (FS, error)
Walk(context.Context, func(*Op) error) error
}
// Something which can be filled in-place with a cue value
type Fillable interface {
Fill(interface{}) error
type Fillable struct {
t *cueflow.Task
}
func Discard() Fillable {
return discard{}
func NewFillable(t *cueflow.Task) *Fillable {
return &Fillable{
t: t,
}
}
type discard struct{}
func (d discard) Fill(x interface{}) error {
return nil
func (f *Fillable) Fill(x interface{}) error {
// Use a nil pointer receiver to discard all values
if f == nil {
return nil
}
return f.t.Fill(x)
}