@@ -180,167 +180,3 @@ func (ai *ActionInvocationInstance) DeepCopy() *ActionInvocationInstance {
180180 ret := * ai
181181 return & ret
182182}
183-
184- // PartialActionTrigger is the equivalent of ActionTrigger but allows the
185- // triggering address to be only partially expanded. This is used during earlier
186- // phases of planning when (for example) count/for_each expansions are not yet
187- // fully resolved.
188- type PartialActionTrigger interface {
189- partialActionTriggerSigil ()
190-
191- TriggerEvent () configs.ActionTriggerEvent
192-
193- String () string
194-
195- Equals (other PartialActionTrigger ) bool
196- }
197-
198- // PartialLifecycleActionTrigger is the partial-expanded form of
199- // LifecycleActionTrigger. It differs only in that it stores a partial-expanded
200- // resource instance address for the triggering resource.
201- type PartialLifecycleActionTrigger struct {
202- TriggeringResourceAddr addrs.PartialExpandedResource
203- ActionTriggerEvent configs.ActionTriggerEvent
204- ActionTriggerBlockIndex int
205- ActionsListIndex int
206- }
207-
208- func (t PartialLifecycleActionTrigger ) partialActionTriggerSigil () {}
209-
210- func (t PartialLifecycleActionTrigger ) TriggerEvent () configs.ActionTriggerEvent {
211- return t .ActionTriggerEvent
212- }
213-
214- func (t PartialLifecycleActionTrigger ) String () string {
215- return t .TriggeringResourceAddr .String ()
216- }
217-
218- func (t PartialLifecycleActionTrigger ) Equals (other PartialActionTrigger ) bool {
219- o , ok := other .(* PartialLifecycleActionTrigger )
220- if ! ok {
221- return false
222- }
223- pomt , tIsPartial := t .TriggeringResourceAddr .PartialExpandedModule ()
224- pemo , oIsPartial := o .TriggeringResourceAddr .PartialExpandedModule ()
225-
226- if tIsPartial != oIsPartial {
227- return false
228- }
229-
230- return pomt .MatchesPartial (pemo ) && t .TriggeringResourceAddr .Resource ().Equal (o .TriggeringResourceAddr .Resource ()) &&
231- t .ActionTriggerEvent == o .ActionTriggerEvent &&
232- t .ActionTriggerBlockIndex == o .ActionTriggerBlockIndex &&
233- t .ActionsListIndex == o .ActionsListIndex
234- }
235-
236- var _ PartialActionTrigger = (* PartialLifecycleActionTrigger )(nil )
237-
238- // PartialExpandedActionInvocationInstance mirrors ActionInvocationInstance
239- // but keeps the action and/or trigger resource addresses in a
240- // partial-expanded form until all dynamic expansions (count, for_each, etc.)
241- // are resolved.
242- type PartialExpandedActionInvocationInstance struct {
243- Addr addrs.PartialExpandedAction
244- ActionTrigger PartialActionTrigger
245- ProviderAddr addrs.AbsProviderConfig
246- ConfigValue cty.Value
247- }
248-
249- // DeepCopy creates a defensive copy of the partial-expanded invocation.
250- func (pii * PartialExpandedActionInvocationInstance ) DeepCopy () * PartialExpandedActionInvocationInstance {
251- if pii == nil {
252- return pii
253- }
254- ret := * pii
255- return & ret
256- }
257-
258- // Equals compares two partial-expanded invocation instances.
259- func (pii * PartialExpandedActionInvocationInstance ) Equals (other * PartialExpandedActionInvocationInstance ) bool {
260- if pii == nil || other == nil {
261- return pii == other
262- }
263- // We compare the (partial) action address and the trigger (which may also
264- // embed a partial address).
265- addrEqual := pii .Addr .Equal (other .Addr )
266- triggerEqual := false
267- if pii .ActionTrigger == nil && other .ActionTrigger == nil {
268- triggerEqual = true
269- } else if pii .ActionTrigger != nil && other .ActionTrigger != nil {
270- triggerEqual = pii .ActionTrigger .Equals (other .ActionTrigger )
271- }
272- return addrEqual && triggerEqual
273- }
274-
275- type PartialExpandedActionInvocationInstanceSrc struct {
276- Addr addrs.PartialExpandedAction
277- ActionTrigger PartialActionTrigger
278- ProviderAddr addrs.AbsProviderConfig
279- ConfigValue DynamicValue
280- SensitiveConfigPaths []cty.Path
281- }
282-
283- // Encode produces a variant of the receiver that has its config value
284- // serialized so it can be written to a plan file while action and trigger
285- // addresses are still in their partial-expanded form. Pass the implied type
286- // of the corresponding action schema for correct operation.
287- func (pii * PartialExpandedActionInvocationInstance ) Encode (schema * providers.ActionSchema ) (* PartialExpandedActionInvocationInstanceSrc , error ) {
288- ret := & PartialExpandedActionInvocationInstanceSrc {
289- Addr : pii .Addr ,
290- ActionTrigger : pii .ActionTrigger ,
291- ProviderAddr : pii .ProviderAddr ,
292- }
293-
294- if pii .ConfigValue != cty .NilVal {
295- ty := cty .DynamicPseudoType
296- if schema != nil {
297- ty = schema .ConfigSchema .ImpliedType ()
298- }
299-
300- unmarkedConfigValue , pvms := pii .ConfigValue .UnmarkDeepWithPaths ()
301- sensitivePaths , otherMarks := marks .PathsWithMark (pvms , marks .Sensitive )
302- if len (otherMarks ) > 0 {
303- return nil , fmt .Errorf ("%s: error serializing partial-expanded action invocation with unexpected marks on config value: %#v. This is a bug in Terraform." , tfdiags .FormatCtyPath (otherMarks [0 ].Path ), otherMarks [0 ].Marks )
304- }
305-
306- var err error
307- ret .ConfigValue , err = NewDynamicValue (unmarkedConfigValue , ty )
308- ret .SensitiveConfigPaths = sensitivePaths
309- if err != nil {
310- return nil , err
311- }
312- }
313-
314- return ret , nil
315- }
316-
317- // Decode produces an in-memory form of the serialized partial-expanded action
318- // invocation instance using the provided schema to infer the original config
319- // value type.
320- func (src * PartialExpandedActionInvocationInstanceSrc ) Decode (schema * providers.ActionSchema ) (* PartialExpandedActionInvocationInstance , error ) {
321- ret := & PartialExpandedActionInvocationInstance {
322- Addr : src .Addr ,
323- ActionTrigger : src .ActionTrigger ,
324- ProviderAddr : src .ProviderAddr ,
325- }
326-
327- if src .ConfigValue != nil {
328- ty := cty .DynamicPseudoType
329- if schema != nil {
330- ty = schema .ConfigSchema .ImpliedType ()
331- }
332-
333- val , err := src .ConfigValue .Decode (ty )
334- if err != nil {
335- return nil , err
336- }
337-
338- if len (src .SensitiveConfigPaths ) > 0 {
339- val = marks .MarkPaths (val , marks .Sensitive , src .SensitiveConfigPaths )
340- }
341-
342- ret .ConfigValue = val
343- }
344-
345- return ret , nil
346- }
0 commit comments