Replace Fillable interface with a concrete wrapper
Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user