Update dagger engine to uses a given architecture instead of default one.

Check #1071 for more details

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau
2021-10-22 20:52:25 +02:00
parent 428aca1c03
commit caa03a37cc
9 changed files with 63 additions and 25 deletions

View File

@@ -7,6 +7,7 @@ import (
"cuelang.org/go/cue"
cueflow "cuelang.org/go/tools/flow"
"github.com/containerd/containerd/platforms"
"go.dagger.io/dagger/compiler"
"go.dagger.io/dagger/solver"
"go.dagger.io/dagger/state"
@@ -137,7 +138,7 @@ func (e *Environment) Up(ctx context.Context, s solver.Solver) error {
flow := cueflow.New(
&cueflow.Config{},
e.src.Cue(),
newTaskFunc(newPipelineRunner(e.computed, s)),
newTaskFunc(newPipelineRunner(e.computed, s, e.state.Architecture)),
)
if err := flow.Run(ctx); err != nil {
return err
@@ -176,7 +177,7 @@ func noOpRunner(t *cueflow.Task) error {
return nil
}
func newPipelineRunner(computed *compiler.Value, s solver.Solver) cueflow.RunnerFunc {
func newPipelineRunner(computed *compiler.Value, s solver.Solver, platform string) cueflow.RunnerFunc {
return cueflow.RunnerFunc(func(t *cueflow.Task) error {
ctx := t.Context()
lg := log.
@@ -197,8 +198,19 @@ func newPipelineRunner(computed *compiler.Value, s solver.Solver) cueflow.Runner
Msg("dependency detected")
}
v := compiler.Wrap(t.Value())
p := NewPipeline(v, s)
err := p.Run(ctx)
platform, err := platforms.Parse(platform)
if err != nil {
// Record the error
span.AddEvent("command", trace.WithAttributes(
attribute.String("error", err.Error()),
))
return err
}
p := NewPipeline(v, s, platform)
err = p.Run(ctx)
if err != nil {
// Record the error
span.AddEvent("command", trace.WithAttributes(