From 06a515f4966e98185844c389c6b865c6a464bc74 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Tue, 1 Jun 2021 14:14:45 +0200 Subject: [PATCH] environments only ignore the compute layer if it is empty instead of logging a fatal error Signed-off-by: Sam Alba --- environment/environment.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/environment/environment.go b/environment/environment.go index 72a7f2e5..a0aa24b7 100644 --- a/environment/environment.go +++ b/environment/environment.go @@ -2,7 +2,6 @@ package environment import ( "context" - "errors" "fmt" "io/fs" "strings" @@ -325,22 +324,20 @@ func (e *Environment) ScanInputs(ctx context.Context, mergeUserInputs bool) ([]* } func (e *Environment) ScanOutputs(ctx context.Context) ([]*compiler.Value, error) { - if e.state.Computed == "" { - return nil, errors.New("environment has been computed yet") - } - src, err := e.prepare(ctx) if err != nil { return nil, err } - computed, err := compiler.DecodeJSON("", []byte(e.state.Computed)) - if err != nil { - return nil, err - } + if e.state.Computed != "" { + computed, err := compiler.DecodeJSON("", []byte(e.state.Computed)) + if err != nil { + return nil, err + } - if err := src.FillPath(cue.MakePath(), computed); err != nil { - return nil, err + if err := src.FillPath(cue.MakePath(), computed); err != nil { + return nil, err + } } return scanOutputs(ctx, src), nil