mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Implement Provider for_each (#2105)
Signed-off-by: ollevche <ollevche@gmail.com> Signed-off-by: Christian Mesh <christianmesh1@gmail.com> Signed-off-by: Ronny Orot <ronny.orot@gmail.com> Signed-off-by: Martin Atkins <mart@degeneration.co.uk> Co-authored-by: ollevche <ollevche@gmail.com> Co-authored-by: Ronny Orot <ronny.orot@gmail.com> Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
@@ -89,7 +89,7 @@ func (ms *Module) RemoveResource(addr addrs.Resource) {
|
||||
//
|
||||
// The provider address is a resource-wide setting and is updated for all other
|
||||
// instances of the same resource as a side-effect of this call.
|
||||
func (ms *Module) SetResourceInstanceCurrent(addr addrs.ResourceInstance, obj *ResourceInstanceObjectSrc, provider addrs.AbsProviderConfig) {
|
||||
func (ms *Module) SetResourceInstanceCurrent(addr addrs.ResourceInstance, obj *ResourceInstanceObjectSrc, provider addrs.AbsProviderConfig, providerKey addrs.InstanceKey) {
|
||||
rs := ms.Resource(addr.Resource)
|
||||
// if the resource is nil and the object is nil, don't do anything!
|
||||
// you'll probably just cause issues
|
||||
@@ -139,6 +139,7 @@ func (ms *Module) SetResourceInstanceCurrent(addr addrs.ResourceInstance, obj *R
|
||||
}
|
||||
// Update the resource's ProviderConfig, in case the provider has updated
|
||||
rs.ProviderConfig = provider
|
||||
is.ProviderKey = providerKey
|
||||
is.Current = obj
|
||||
}
|
||||
|
||||
@@ -158,11 +159,12 @@ func (ms *Module) SetResourceInstanceCurrent(addr addrs.ResourceInstance, obj *R
|
||||
// is overwritten. Set obj to nil to remove the deposed object altogether. If
|
||||
// the instance is left with no objects after this operation then it will
|
||||
// be removed from its containing resource altogether.
|
||||
func (ms *Module) SetResourceInstanceDeposed(addr addrs.ResourceInstance, key DeposedKey, obj *ResourceInstanceObjectSrc, provider addrs.AbsProviderConfig) {
|
||||
func (ms *Module) SetResourceInstanceDeposed(addr addrs.ResourceInstance, key DeposedKey, obj *ResourceInstanceObjectSrc, provider addrs.AbsProviderConfig, providerKey addrs.InstanceKey) {
|
||||
ms.SetResourceProvider(addr.Resource, provider)
|
||||
|
||||
rs := ms.Resource(addr.Resource)
|
||||
is := rs.EnsureInstance(addr.Key)
|
||||
is.ProviderKey = providerKey
|
||||
if obj != nil {
|
||||
is.Deposed[key] = obj
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user