func (i *ResourceInstance) FindUnusedDeposedKey() DeposedKey {
	return i.findUnusedDeposedKey()
}
FindUnusedDeposedKey generates a unique DeposedKey that is guaranteed not to
already be in use for this instance at the time of the call.

Note that the validity of this result may change if new deposed keys are
allocated before it is used. To avoid this risk, instead use the
DeposeResourceInstanceObject method on the SyncState wrapper type, which
allocates a key and uses it atomically.
package states
import (
	"fmt"
	"math/rand"
	"time"
	"github.com/camptocamp/terraboard/internal/terraform/addrs"
)
type Resource struct {
	Addr addrs.AbsResource
	Instances map[addrs.InstanceKey]*ResourceInstance
	ProviderConfig addrs.AbsProviderConfig
}
func (rs *Resource) Instance(key addrs.InstanceKey) *ResourceInstance {
	return rs.Instances[key]
}
func (rs *Resource) CreateInstance(key addrs.InstanceKey) *ResourceInstance {
	is := NewResourceInstance()
	rs.Instances[key] = is
	return is
}
func (rs *Resource) EnsureInstance(key addrs.InstanceKey) *ResourceInstance {
	ret := rs.Instance(key)
	if ret == nil {
		ret = NewResourceInstance()
		rs.Instances[key] = ret
	}
	return ret
}
type ResourceInstance struct {
	Current *ResourceInstanceObjectSrc
	Deposed map[DeposedKey]*ResourceInstanceObjectSrc
}
func NewResourceInstance() *ResourceInstance {
	return &ResourceInstance{
		Deposed: map[DeposedKey]*ResourceInstanceObjectSrc{},
	}
}
func (i *ResourceInstance) HasCurrent() bool {
	return i != nil && i.Current != nil
}
func (i *ResourceInstance) HasDeposed(key DeposedKey) bool {
	return i != nil && i.Deposed[key] != nil
}
func (i *ResourceInstance) HasAnyDeposed() bool {
	return i != nil && len(i.Deposed) > 0
}
func (i *ResourceInstance) HasObjects() bool {
	return i.Current != nil || len(i.Deposed) != 0
}
func (i *ResourceInstance) deposeCurrentObject(forceKey DeposedKey) DeposedKey {
	if !i.HasCurrent() {
		return NotDeposed
	}
	key := forceKey
	if key == NotDeposed {
		key = i.findUnusedDeposedKey()
	} else {
		if _, exists := i.Deposed[key]; exists {
			panic(fmt.Sprintf("forced key %s is already in use", forceKey))
		}
	}
	i.Deposed[key] = i.Current
	i.Current = nil
	return key
}
func (i *ResourceInstance) GetGeneration(gen Generation) *ResourceInstanceObjectSrc {
	if gen == CurrentGen {
		return i.Current
	}
	if dk, ok := gen.(DeposedKey); ok {
		return i.Deposed[dk]
	}
	if gen == nil {
		panic("get with nil Generation")
	}
	panic(fmt.Sprintf("get invalid Generation %#v", gen))
}