From 4a461a002197290fb002942637a8dc88ea218bbd Mon Sep 17 00:00:00 2001 From: Tom Chauveau Date: Sat, 30 Oct 2021 12:07:33 +0200 Subject: [PATCH] Fix engine to don't write architecture in values.yaml if no one provided. Signed-off-by: Tom Chauveau --- cmd/dagger/cmd/compute.go | 3 ++- environment/environment.go | 25 ++++++++++++++++--------- state/project.go | 10 ---------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/cmd/dagger/cmd/compute.go b/cmd/dagger/cmd/compute.go index 4dbc3b5d..be5c7ddb 100644 --- a/cmd/dagger/cmd/compute.go +++ b/cmd/dagger/cmd/compute.go @@ -10,6 +10,7 @@ import ( "cuelang.org/go/cue" "github.com/containerd/containerd/platforms" + specs "github.com/opencontainers/image-spec/specs-go/v1" "go.dagger.io/dagger/cmd/dagger/cmd/common" "go.dagger.io/dagger/cmd/dagger/logger" "go.dagger.io/dagger/compiler" @@ -43,7 +44,7 @@ var computeCmd = &cobra.Command{ st := &state.State{ Name: "FIXME", - Architecture: platforms.Format(platforms.DefaultSpec()), + Architecture: platforms.Format(specs.Platform{OS: "linux", Architecture: "amd64"}), Path: args[0], Plan: state.Plan{ Module: args[0], diff --git a/environment/environment.go b/environment/environment.go index 164ef9fb..d6419824 100644 --- a/environment/environment.go +++ b/environment/environment.go @@ -8,6 +8,7 @@ import ( "cuelang.org/go/cue" cueflow "cuelang.org/go/tools/flow" "github.com/containerd/containerd/platforms" + specs "github.com/opencontainers/image-spec/specs-go/v1" "go.dagger.io/dagger/compiler" "go.dagger.io/dagger/solver" "go.dagger.io/dagger/state" @@ -199,18 +200,24 @@ func newPipelineRunner(computed *compiler.Value, s solver.Solver, platform strin } v := compiler.Wrap(t.Value()) - platform, err := platforms.Parse(platform) - if err != nil { - // Record the error - span.AddEvent("command", trace.WithAttributes( - attribute.String("error", err.Error()), - )) + var pipelinePlatform specs.Platform + if platform == "" { + pipelinePlatform = specs.Platform{OS: "linux", Architecture: "amd64"} + } else { + p, err := platforms.Parse(platform) + if err != nil { + // Record the error + span.AddEvent("command", trace.WithAttributes( + attribute.String("error", err.Error()), + )) - return err + return err + } + pipelinePlatform = p } - p := NewPipeline(v, s, platform) - err = p.Run(ctx) + p := NewPipeline(v, s, pipelinePlatform) + err := p.Run(ctx) if err != nil { // Record the error span.AddEvent("command", trace.WithAttributes( diff --git a/state/project.go b/state/project.go index 4da2901d..c9a2a5f6 100644 --- a/state/project.go +++ b/state/project.go @@ -10,8 +10,6 @@ import ( "path/filepath" "strings" - "github.com/containerd/containerd/platforms" - specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/rs/zerolog/log" "go.dagger.io/dagger/keychain" "go.dagger.io/dagger/stdlib" @@ -184,10 +182,6 @@ func (w *Project) Get(ctx context.Context, name string) (*State, error) { } st.Project = w.Path - if st.Architecture == "" { - st.Architecture = platforms.DefaultString() - } - computed, err := os.ReadFile(path.Join(envPath, stateDir, computedFile)) if err == nil { st.Computed = string(computed) @@ -263,10 +257,6 @@ func (w *Project) Create(ctx context.Context, name string, plan Plan, arch strin manifestPath := path.Join(envPath, manifestFile) - if arch == "" { - arch = platforms.Format(specs.Platform{OS: "linux", Architecture: "amd64"}) - } - st := &State{ Path: envPath, Project: w.Path,