From e0ab23a04070d173a972622213a4c376f6f214cf Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Thu, 17 Jul 2025 16:15:20 +0200 Subject: [PATCH] ensure we encode action invocations from change to changesrc --- internal/plans/action_invocation.go | 3 +-- internal/plans/changes.go | 8 ++++++++ internal/plans/changes_src.go | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/internal/plans/action_invocation.go b/internal/plans/action_invocation.go index bacfff1e72..87223e1e7c 100644 --- a/internal/plans/action_invocation.go +++ b/internal/plans/action_invocation.go @@ -5,7 +5,6 @@ package plans import ( "github.com/hashicorp/terraform/internal/addrs" - "github.com/hashicorp/terraform/internal/providers" ) type ActionInvocationInstance struct { @@ -20,7 +19,7 @@ type ActionInvocationInstance struct { // Encode produces a variant of the receiver that has its change values // serialized so it can be written to a plan file. Pass the implied type of the // corresponding resource type schema for correct operation. -func (ai *ActionInvocationInstance) Encode(schema providers.Schema) (*ActionInvocationInstanceSrc, error) { +func (ai *ActionInvocationInstance) Encode() (*ActionInvocationInstanceSrc, error) { return &ActionInvocationInstanceSrc{ Addr: ai.Addr, ProviderAddr: ai.ProviderAddr, diff --git a/internal/plans/changes.go b/internal/plans/changes.go index 209a650838..f827edb33a 100644 --- a/internal/plans/changes.go +++ b/internal/plans/changes.go @@ -98,6 +98,14 @@ func (c *Changes) Encode(schemas *schemarepo.Schemas) (*ChangesSrc, error) { changesSrc.Queries = append(changesSrc.Queries, rcs) } + for _, ai := range c.ActionInvocations { + a, err := ai.Encode() + if err != nil { + return changesSrc, fmt.Errorf("Changes.Encode: %w", err) + } + changesSrc.ActionInvocations = append(changesSrc.ActionInvocations, a) + } + for _, ocs := range c.Outputs { oc, err := ocs.Encode() if err != nil { diff --git a/internal/plans/changes_src.go b/internal/plans/changes_src.go index 8cff2688eb..312e945883 100644 --- a/internal/plans/changes_src.go +++ b/internal/plans/changes_src.go @@ -29,7 +29,7 @@ type ChangesSrc struct { // ActionInvocations tracks planned action invocations, which may have // embedded resource instance changes. - Actions []*ActionInvocationInstanceSrc + ActionInvocations []*ActionInvocationInstanceSrc // Outputs tracks planned changes output values. // @@ -159,7 +159,7 @@ func (c *ChangesSrc) Decode(schemas *schemarepo.Schemas) (*Changes, error) { changes.Queries = append(changes.Queries, query) } - for _, ais := range c.Actions { + for _, ais := range c.ActionInvocations { p, ok := schemas.Providers[ais.ProviderAddr.Provider] if !ok { return nil, fmt.Errorf("ChangesSrc.Decode: missing provider %s for action %s", ais.ProviderAddr, ais.Addr) @@ -557,7 +557,7 @@ func (c *ChangesSrc) AppendActionInvocationInstanceChange(action *ActionInvocati } a := action.DeepCopy() - c.Actions = append(c.Actions, a) + c.ActionInvocations = append(c.ActionInvocations, a) } type ActionInvocationInstanceSrc struct {