cleanup unused CBD code
Remove the check for CreateBeforeDestroyOverride which can't happen in a destroy node. Remove the unnecessary GraphNodeAttachDestroyer interface, since we don't use it now that plans can record the create+destroy order.
This commit is contained in:
parent
67fd32db7e
commit
a6dffa89a3
|
@ -21,7 +21,6 @@ import (
|
|||
type NodeApplyableResourceInstance struct {
|
||||
*NodeAbstractResourceInstance
|
||||
|
||||
destroyNode GraphNodeDestroyerCBD
|
||||
graphNodeDeposer // implementation of GraphNodeDeposerConfig
|
||||
|
||||
// If this node is forced to be CreateBeforeDestroy, we need to record that
|
||||
|
@ -39,13 +38,7 @@ var (
|
|||
_ GraphNodeAttachDependencies = (*NodeApplyableResourceInstance)(nil)
|
||||
)
|
||||
|
||||
// GraphNodeAttachDestroyer
|
||||
func (n *NodeApplyableResourceInstance) AttachDestroyNode(d GraphNodeDestroyerCBD) {
|
||||
n.destroyNode = d
|
||||
}
|
||||
|
||||
// CreateBeforeDestroy checks this nodes config status and the status af any
|
||||
// companion destroy node for CreateBeforeDestroy.
|
||||
// CreateBeforeDestroy returns this node's CreateBeforeDestroy status.
|
||||
func (n *NodeApplyableResourceInstance) CreateBeforeDestroy() bool {
|
||||
if n.ForceCreateBeforeDestroy {
|
||||
return n.ForceCreateBeforeDestroy
|
||||
|
@ -55,10 +48,6 @@ func (n *NodeApplyableResourceInstance) CreateBeforeDestroy() bool {
|
|||
return n.Config.Managed.CreateBeforeDestroy
|
||||
}
|
||||
|
||||
if n.destroyNode != nil {
|
||||
return n.destroyNode.CreateBeforeDestroy()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ type NodeDestroyResourceInstance struct {
|
|||
// this node destroys a deposed object of the associated instance
|
||||
// rather than its current object.
|
||||
DeposedKey states.DeposedKey
|
||||
|
||||
CreateBeforeDestroyOverride *bool
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -63,10 +61,6 @@ func (n *NodeDestroyResourceInstance) CreateBeforeDestroy() bool {
|
|||
}
|
||||
}
|
||||
|
||||
if n.CreateBeforeDestroyOverride != nil {
|
||||
return *n.CreateBeforeDestroyOverride
|
||||
}
|
||||
|
||||
if n.Config != nil && n.Config.Managed != nil {
|
||||
return n.Config.Managed.CreateBeforeDestroy
|
||||
}
|
||||
|
@ -76,7 +70,6 @@ func (n *NodeDestroyResourceInstance) CreateBeforeDestroy() bool {
|
|||
|
||||
// GraphNodeDestroyerCBD
|
||||
func (n *NodeDestroyResourceInstance) ModifyCreateBeforeDestroy(v bool) error {
|
||||
n.CreateBeforeDestroyOverride = &v
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -23,20 +23,6 @@ type GraphNodeDestroyerCBD interface {
|
|||
ModifyCreateBeforeDestroy(bool) error
|
||||
}
|
||||
|
||||
// GraphNodeAttachDestroyer is implemented by applyable nodes that have a
|
||||
// companion destroy node. This allows the creation node to look up the status
|
||||
// of the destroy node and determine if it needs to depose the existing state,
|
||||
// or replace it.
|
||||
// If a node is not marked as create-before-destroy in the configuration, but a
|
||||
// dependency forces that status, only the destroy node will be aware of that
|
||||
// status.
|
||||
type GraphNodeAttachDestroyer interface {
|
||||
// AttachDestroyNode takes a destroy node and saves a reference to that
|
||||
// node in the receiver, so it can later check the status of
|
||||
// CreateBeforeDestroy().
|
||||
AttachDestroyNode(n GraphNodeDestroyerCBD)
|
||||
}
|
||||
|
||||
// ForcedCBDTransformer detects when a particular CBD-able graph node has
|
||||
// dependencies with another that has create_before_destroy set that require
|
||||
// it to be forced on, and forces it on.
|
||||
|
|
|
@ -157,16 +157,6 @@ func (t *DestroyEdgeTransformer) Transform(g *Graph) error {
|
|||
dag.VertexName(a), dag.VertexName(a_d))
|
||||
|
||||
g.Connect(dag.BasicEdge(a, a_d))
|
||||
|
||||
// Attach the destroy node to the creator
|
||||
// There really shouldn't be more than one destroyer, but even if
|
||||
// there are, any of them will represent the correct
|
||||
// CreateBeforeDestroy status.
|
||||
if n, ok := cn.(GraphNodeAttachDestroyer); ok {
|
||||
if d, ok := d.(GraphNodeDestroyerCBD); ok {
|
||||
n.AttachDestroyNode(d)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue