@@ -493,7 +493,6 @@ func (pc *PlannedChangeResourceInstancePlanned) ChangeDescription() (*stacks.Pla
493493 },
494494 },
495495 }, nil
496-
497496}
498497
499498func DynamicValueToTerraform1 (val cty.Value , ty cty.Type ) (* stacks.DynamicValue , error ) {
@@ -853,3 +852,113 @@ func (pc *PlannedChangeProviderFunctionResults) PlannedChangeProto() (*stacks.Pl
853852 Raw : []* anypb.Any {& raw },
854853 }, nil
855854}
855+
856+ type PlannedChangeActionInvocationInstancePlanned struct {
857+ ActionInvocationAddr stackaddrs.AbsActionInvocationInstance
858+
859+ // Invocation describes the planned invocation.
860+ Invocation * plans.ActionInvocationInstanceSrc
861+
862+ // ProviderConfigAddr is the address of the provider configuration
863+ // that planned this change, resolved in terms of the configuration for
864+ // the component this resource instance object belongs to.
865+ ProviderConfigAddr addrs.AbsProviderConfig
866+
867+ // Schema MUST be the same schema that was used to encode the dynamic
868+ // values inside ChangeSrc
869+ //
870+ // Can be empty if and only if ChangeSrc is nil.
871+ Schema providers.ActionSchema
872+ }
873+
874+ var _ PlannedChange = (* PlannedChangeActionInvocationInstancePlanned )(nil )
875+
876+ func (pc * PlannedChangeActionInvocationInstancePlanned ) PlanActionInvocationProto () (* tfstackdata1.PlanActionInvocationPlanned , error ) {
877+ addr := pc .ActionInvocationAddr
878+
879+ if pc .Invocation == nil {
880+ // This is just a stubby placeholder to remind us to drop the
881+ // apparently-deleted-outside-of-Terraform object from the state
882+ // if this plan later gets applied.
883+
884+ return & tfstackdata1.PlanActionInvocationPlanned {
885+ ComponentInstanceAddr : addr .Component .String (),
886+ ActionInvocationAddr : addr .Item .String (),
887+ ProviderConfigAddr : pc .ProviderConfigAddr .String (),
888+ }, nil
889+ }
890+
891+ invocationProto , err := planfile .ActionInvocationToProto (pc .Invocation )
892+ if err != nil {
893+ return nil , fmt .Errorf ("converting action invocation to proto: %w" , err )
894+ }
895+
896+ return & tfstackdata1.PlanActionInvocationPlanned {
897+ ComponentInstanceAddr : addr .Component .String (),
898+ ActionInvocationAddr : addr .Item .String (),
899+ ProviderConfigAddr : pc .ProviderConfigAddr .String (),
900+ Invocation : invocationProto ,
901+ }, nil
902+ }
903+
904+ func (pc * PlannedChangeActionInvocationInstancePlanned ) ChangeDescription () (* stacks.PlannedChange_ChangeDescription , error ) {
905+ addr := pc .ActionInvocationAddr
906+
907+ // We only emit an external description if there's an invocation to describe.
908+ if pc .Invocation == nil {
909+ return nil , nil
910+ }
911+
912+ return & stacks.PlannedChange_ChangeDescription {
913+ Description : & stacks.PlannedChange_ChangeDescription_ActionInvocationPlanned {
914+ ActionInvocationPlanned : & stacks.PlannedChange_ActionInvocationInstance {
915+ Addr : stacks .NewActionInvocationInStackAddr (addr ),
916+ ProviderAddr : pc .Invocation .ProviderAddr .Provider .String (),
917+
918+ ConfigValue : stacks .NewDynamicValue (
919+ pc .Invocation .ConfigValue ,
920+ pc .Invocation .SensitiveConfigPaths ,
921+ ),
922+
923+ ActionTrigger : nil ,
924+ },
925+ },
926+ }, nil
927+ }
928+
929+ // PlannedChangeProto implements PlannedChange.
930+ func (pc * PlannedChangeActionInvocationInstancePlanned ) PlannedChangeProto () (* stacks.PlannedChange , error ) {
931+ paip , err := pc .PlanActionInvocationProto ()
932+ if err != nil {
933+ return nil , err
934+ }
935+ var raw anypb.Any
936+ err = anypb .MarshalFrom (& raw , paip , proto.MarshalOptions {})
937+ if err != nil {
938+ return nil , err
939+ }
940+
941+ if pc .Invocation == nil {
942+ // We only emit a "raw" in this case, because this is a relatively
943+ // uninteresting edge-case. The PlanActionInvocationProto
944+ // function should have returned a placeholder value for this use case.
945+
946+ return & stacks.PlannedChange {
947+ Raw : []* anypb.Any {& raw },
948+ }, nil
949+ }
950+
951+ var descs []* stacks.PlannedChange_ChangeDescription
952+ desc , err := pc .ChangeDescription ()
953+ if err != nil {
954+ return nil , err
955+ }
956+ if desc != nil {
957+ descs = append (descs , desc )
958+ }
959+
960+ return & stacks.PlannedChange {
961+ Raw : []* anypb.Any {& raw },
962+ Descriptions : descs ,
963+ }, nil
964+ }
0 commit comments