cue native: environments can reference a module instead of embedding

one.

Fixes #631

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-06-15 18:49:57 +02:00
committed by Solomon Hykes
parent 8de58eb3d0
commit f39a88e644
11 changed files with 181 additions and 34 deletions

View File

@@ -65,10 +65,6 @@ func (e *Environment) Name() string {
return e.state.Name
}
func (e *Environment) PlanSource() state.Input {
return e.state.PlanSource()
}
func (e *Environment) Plan() *compiler.Value {
return e.plan
}
@@ -86,7 +82,7 @@ func (e *Environment) LoadPlan(ctx context.Context, s solver.Solver) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "environment.LoadPlan")
defer span.Finish()
planSource, err := e.state.PlanSource().Compile("", e.state)
planSource, err := e.state.Plan.Source().Compile("", e.state)
if err != nil {
return err
}
@@ -102,7 +98,11 @@ func (e *Environment) LoadPlan(ctx context.Context, s solver.Solver) error {
stdlib.Path: stdlib.FS,
"/": p.FS(),
}
plan, err := compiler.Build(sources)
args := []string{}
if pkg := e.state.Plan.Package; pkg != "" {
args = append(args, pkg)
}
plan, err := compiler.Build(sources, args...)
if err != nil {
return fmt.Errorf("plan config: %w", compiler.Err(err))
}
@@ -157,7 +157,7 @@ func (e *Environment) LocalDirs() map[string]string {
}
// 2. Scan the plan
plan, err := e.state.PlanSource().Compile("", e.state)
plan, err := e.state.Plan.Source().Compile("", e.state)
if err != nil {
panic(err)
}