Skip to content

Commit

Permalink
fix: don't read outputs for site without components
Browse files Browse the repository at this point in the history
  • Loading branch information
demeyerthom committed Jan 21, 2025
1 parent d3705ac commit 9279aa1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Fixed-20250121-122320.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Fixed
body: Don't read outputs for site without components
time: 2025-01-21T12:23:20.045132931+01:00
13 changes: 13 additions & 0 deletions internal/runner/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runner

import (
"context"
"fmt"
"github.com/mach-composer/mach-composer-cli/internal/graph"
"github.com/mach-composer/mach-composer-cli/internal/utils"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -32,6 +33,18 @@ func terraformCanPlan(ctx context.Context, n graph.Node) (bool, error) {
}

for _, parent := range parents {
if parent.Type() == graph.SiteType {
sp, ok := parent.(*graph.Site)
if !ok {
return false, fmt.Errorf("failed to cast parent to site")
}

if len(sp.NestedNodes) == 0 {
log.Debug().Msgf("site node does not contain components, so no output is available")
continue
}
}

v, err := utils.GetTerraformOutputs(ctx, parent.Path())
if err != nil {
return false, nil
Expand Down

0 comments on commit 9279aa1

Please sign in to comment.