From 5f4ff0e8be5df05f2ad21f093feb1bb8738ac91b Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 17 Nov 2020 09:31:18 -0500 Subject: [PATCH] don't render plan for module outputs Module outputs should not trigger plan rendering. --- plans/changes.go | 2 +- plans/plan_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/plans/changes.go b/plans/changes.go index 414099488..72b6a8938 100644 --- a/plans/changes.go +++ b/plans/changes.go @@ -39,7 +39,7 @@ func (c *Changes) Empty() bool { } for _, out := range c.Outputs { - if out.Action != NoOp { + if out.Addr.Module.IsRoot() && out.Action != NoOp { return false } } diff --git a/plans/plan_test.go b/plans/plan_test.go index 012ff06a6..b8a0e4501 100644 --- a/plans/plan_test.go +++ b/plans/plan_test.go @@ -68,3 +68,28 @@ func TestProviderAddrs(t *testing.T) { t.Error(problem) } } + +// Module outputs should not effect the result of Empty +func TestModuleOutputChangesEmpty(t *testing.T) { + changes := &Changes{ + Outputs: []*OutputChangeSrc{ + { + Addr: addrs.AbsOutputValue{ + Module: addrs.RootModuleInstance.Child("child", addrs.NoKey), + OutputValue: addrs.OutputValue{ + Name: "output", + }, + }, + ChangeSrc: ChangeSrc{ + Action: Update, + Before: []byte("a"), + After: []byte("b"), + }, + }, + }, + } + + if !changes.Empty() { + t.Fatal("plan has no visible changes") + } +}