@@ -1000,3 +1000,61 @@ func (pc *PlannedChangeActionInvocationInstancePlanned) PlannedChangeProto() (*s
10001000 Descriptions : descs ,
10011001 }, nil
10021002}
1003+
1004+ // PlannedChangeDeferredActionInvocationPlanned announces that an invocation that Terraform
1005+ // is proposing to take if this plan is applied is being deferred.
1006+ type PlannedChangeDeferredActionInvocationPlanned struct {
1007+ // ActionInvocationPlanned is the planned invocation that is being deferred.
1008+ ActionInvocationPlanned PlannedChangeActionInvocationInstancePlanned
1009+
1010+ // DeferredReason is the reason why the change is being deferred.
1011+ DeferredReason providers.DeferredReason
1012+ }
1013+
1014+ var _ PlannedChange = (* PlannedChangeDeferredActionInvocationPlanned )(nil )
1015+
1016+ // PlannedChangeProto implements PlannedChange.
1017+ func (dai * PlannedChangeDeferredActionInvocationPlanned ) PlannedChangeProto () (* stacks.PlannedChange , error ) {
1018+ invocation , err := dai .ActionInvocationPlanned .PlanActionInvocationProto ()
1019+ if err != nil {
1020+ return nil , err
1021+ }
1022+
1023+ // We'll ignore the error here. We certainly should not have got this far
1024+ // if we have a deferred reason that the Terraform Core runtime doesn't
1025+ // recognise. There will be diagnostics elsewhere to reflect this, as we
1026+ // can just use INVALID to capture this. This also makes us forwards and
1027+ // backwards compatible, as we'll return INVALID for any new deferred
1028+ // reasons that are added in the future without erroring.
1029+ deferredReason , _ := planfile .DeferredReasonToProto (dai .DeferredReason )
1030+
1031+ var raw anypb.Any
1032+ err = anypb .MarshalFrom (& raw , & tfstackdata1.PlanDeferredActionInvocation {
1033+ Invocation : invocation ,
1034+ Deferred : & planproto.Deferred {
1035+ Reason : deferredReason ,
1036+ },
1037+ }, proto.MarshalOptions {})
1038+ if err != nil {
1039+ return nil , err
1040+ }
1041+ desc , err := dai .ActionInvocationPlanned .ChangeDescription ()
1042+ if err != nil {
1043+ return nil , err
1044+ }
1045+
1046+ var descs []* stacks.PlannedChange_ChangeDescription
1047+ descs = append (descs , & stacks.PlannedChange_ChangeDescription {
1048+ Description : & stacks.PlannedChange_ChangeDescription_ActionInvocationDeferred {
1049+ ActionInvocationDeferred : & stacks.PlannedChange_ActionInvocationDeferred {
1050+ ActionInvocation : desc .GetActionInvocationPlanned (),
1051+ Deferred : EncodeDeferred (dai .DeferredReason ),
1052+ },
1053+ },
1054+ })
1055+
1056+ return & stacks.PlannedChange {
1057+ Raw : []* anypb.Any {& raw },
1058+ Descriptions : descs ,
1059+ }, nil
1060+ }
0 commit comments