Simplify runtime code by removing layers of abstraction
- Remove intermediary types `Component`, `Script`, `Op`, `mount`: just use `cc.Value` directly - Remove `Executable` interface. - Execute llb code with a simple concrete type `Pipeline` - Analyze llb code with a simple utility `Analyze` Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
@@ -1,38 +1,13 @@
|
||||
package dagger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
cueflow "cuelang.org/go/tools/flow"
|
||||
|
||||
"dagger.cloud/go/dagger/cc"
|
||||
)
|
||||
|
||||
var ErrNotExist = os.ErrNotExist
|
||||
|
||||
// Implemented by Component, Script, Op
|
||||
type Executable interface {
|
||||
Execute(context.Context, FS, *Fillable) (FS, error)
|
||||
Walk(context.Context, func(*Op) error) error
|
||||
}
|
||||
|
||||
func newExecutable(v *cc.Value) (Executable, error) {
|
||||
// NOTE: here we need full spec validation,
|
||||
// so we call NewScript, NewComponent, NewOp.
|
||||
if script, err := NewScript(v); err == nil {
|
||||
return script, nil
|
||||
}
|
||||
if component, err := NewComponent(v); err == nil {
|
||||
return component, nil
|
||||
}
|
||||
if op, err := NewOp(v); err == nil {
|
||||
return op, nil
|
||||
}
|
||||
return nil, fmt.Errorf("value is not executable")
|
||||
}
|
||||
|
||||
// Something which can be filled in-place with a cue value
|
||||
type Fillable struct {
|
||||
t *cueflow.Task
|
||||
|
Reference in New Issue
Block a user