ensure we encode action invocations from change to changesrc

pull/37347/head
Daniel Schmidt 9 months ago
parent 303dc90f17
commit e0ab23a040

@ -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,

@ -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 {

@ -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 {

Loading…
Cancel
Save