@@ -108,10 +108,6 @@ func (gr *GraphRunner) run(ctx context.Context, g *graph.Graph, f executorFunc,
108108 errChan <- err
109109 return
110110 }
111-
112- if err != nil {
113- errChan <- err
114- }
115111 }(ctx , n )
116112 }
117113 wg .Wait ()
@@ -167,7 +163,7 @@ func (gr *GraphRunner) TerraformApply(ctx context.Context, dg *graph.Graph, opts
167163
168164 out , err := terraform .Apply (ctx , n .Path (), aOpts ... )
169165 if err != nil {
170- return err
166+ err = fmt . Errorf ( "failed to apply %s: %w" , n . Identifier (), err )
171167 }
172168
173169 if cli .OutputFromContext (ctx ) == cli .OutputTypeJSON {
@@ -186,12 +182,12 @@ func (gr *GraphRunner) TerraformApply(ctx context.Context, dg *graph.Graph, opts
186182 log .Ctx (ctx ).Info ().Msg (out )
187183 }
188184
189- log .Ctx (ctx ).Info ().Msgf ("Storing new hash for %s" , n .Path ())
185+ log .Ctx (ctx ).Debug ().Msgf ("Storing new hash for %s" , n .Path ())
190186 if err := gr .hash .Store (ctx , n ); err != nil {
191187 log .Ctx (ctx ).Warn ().Err (err ).Msgf ("Failed to store hash for %s" , n .Identifier ())
192188 }
193189
194- return nil
190+ return err
195191
196192 }, opts .IgnoreChangeDetection ); err != nil {
197193 return err
@@ -215,11 +211,11 @@ func (gr *GraphRunner) TerraformValidate(ctx context.Context, dg *graph.Graph) e
215211
216212 out , err = terraform .Validate (ctx , n .Path (), vOpts ... )
217213 if err != nil {
218- return err
214+ err = fmt . Errorf ( "failed to validate %s: %w" , n . Identifier (), err )
219215 }
220216 log .Ctx (ctx ).Info ().Msg (out )
221217
222- return nil
218+ return err
223219 }, true )
224220}
225221
@@ -256,7 +252,7 @@ func (gr *GraphRunner) TerraformPlan(ctx context.Context, dg *graph.Graph, opts
256252
257253 out , err := terraform .Plan (ctx , n .Path (), pOpts ... )
258254 if err != nil {
259- return err
255+ err = fmt . Errorf ( "failed to plan %s: %w" , n . Identifier (), err )
260256 }
261257
262258 if cli .OutputFromContext (ctx ) == cli .OutputTypeJSON {
@@ -275,7 +271,7 @@ func (gr *GraphRunner) TerraformPlan(ctx context.Context, dg *graph.Graph, opts
275271 log .Ctx (ctx ).Info ().Msg (out )
276272 }
277273
278- return nil
274+ return err
279275 }, opts .IgnoreChangeDetection ); err != nil {
280276 return err
281277 }
@@ -291,10 +287,10 @@ func (gr *GraphRunner) TerraformProxy(ctx context.Context, dg *graph.Graph, opts
291287
292288 out , err := utils .RunTerraform (ctx , n .Path (), opts .Command ... )
293289 if err != nil {
294- return err
290+ err = fmt . Errorf ( "failed to proxy %s: %w" , n . Identifier (), err )
295291 }
296292 log .Ctx (ctx ).Info ().Msg (out )
297- return nil
293+ return err
298294 }, opts .IgnoreChangeDetection ); err != nil {
299295 return err
300296 }
@@ -325,7 +321,7 @@ func (gr *GraphRunner) TerraformShow(ctx context.Context, dg *graph.Graph, opts
325321
326322 out , err := terraform .Show (ctx , n .Path (), sOpts ... )
327323 if err != nil {
328- return err
324+ err = fmt . Errorf ( "failed to show %s: %w" , n . Identifier (), err )
329325 }
330326
331327 if cli .OutputFromContext (ctx ) == cli .OutputTypeJSON {
@@ -343,7 +339,7 @@ func (gr *GraphRunner) TerraformShow(ctx context.Context, dg *graph.Graph, opts
343339 } else {
344340 log .Ctx (ctx ).Info ().Msg (out )
345341 }
346- return nil
342+ return err
347343 }, opts .IgnoreChangeDetection ); err != nil {
348344 return err
349345 }
@@ -355,10 +351,10 @@ func (gr *GraphRunner) TerraformInit(ctx context.Context, dg *graph.Graph) error
355351 if err := gr .run (ctx , dg , func (ctx context.Context , n graph.Node ) error {
356352 out , err := terraform .Init (ctx , n .Path ())
357353 if err != nil {
358- return err
354+ err = fmt . Errorf ( "failed to init %s: %w" , n . Identifier (), err )
359355 }
360356 log .Ctx (ctx ).Info ().Msg (out )
361- return nil
357+ return err
362358 }, true ); err != nil {
363359 return err
364360 }
0 commit comments