Incremental cleanup: wrap env instance in a Value
Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
parent
795b7f585c
commit
bbe16283ab
@ -22,6 +22,9 @@ type Env struct {
|
|||||||
// Buildkit solver
|
// Buildkit solver
|
||||||
s Solver
|
s Solver
|
||||||
|
|
||||||
|
// Full cue state (base + input + output)
|
||||||
|
state *Value
|
||||||
|
|
||||||
// shared cue compiler
|
// shared cue compiler
|
||||||
// (because cue API requires shared runtime for everything)
|
// (because cue API requires shared runtime for everything)
|
||||||
cc *Compiler
|
cc *Compiler
|
||||||
@ -60,10 +63,13 @@ func NewEnv(ctx context.Context, s Solver, bootsrc, inputsrc string) (*Env, erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Check that input can be merged on base
|
// Merge base + input into a new cue instance
|
||||||
if _, err := base.Merge(input); err != nil {
|
// FIXME: make this cleaner in *Value by keeping intermediary instances
|
||||||
|
stateInst, err := base.CueInst().Fill(input.CueInst().Value())
|
||||||
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "merge base & input")
|
return nil, errors.Wrap(err, "merge base & input")
|
||||||
}
|
}
|
||||||
|
state := cc.Wrap(stateInst.Value(), stateInst)
|
||||||
|
|
||||||
lg.
|
lg.
|
||||||
Debug().
|
Debug().
|
||||||
@ -74,6 +80,7 @@ func NewEnv(ctx context.Context, s Solver, bootsrc, inputsrc string) (*Env, erro
|
|||||||
return &Env{
|
return &Env{
|
||||||
base: base,
|
base: base,
|
||||||
input: input,
|
input: input,
|
||||||
|
state: state,
|
||||||
s: s,
|
s: s,
|
||||||
cc: cc,
|
cc: cc,
|
||||||
}, nil
|
}, nil
|
||||||
@ -126,12 +133,7 @@ func (env *Env) Walk(ctx context.Context, fn EnvWalkFunc) (*Value, error) {
|
|||||||
lg := log.Ctx(ctx)
|
lg := log.Ctx(ctx)
|
||||||
|
|
||||||
// Cueflow cue instance
|
// Cueflow cue instance
|
||||||
// FIXME: make this cleaner in *Value by keeping intermediary instances
|
flowInst := env.state.CueInst()
|
||||||
flowInst, err := env.base.CueInst().Fill(env.input.CueInst().Value())
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
lg.
|
lg.
|
||||||
Debug().
|
Debug().
|
||||||
Str("value", env.cc.Wrap(flowInst.Value(), flowInst).JSON().String()).
|
Str("value", env.cc.Wrap(flowInst.Value(), flowInst).JSON().String()).
|
||||||
|
Reference in New Issue
Block a user