terraform: keep pruning out lines

This commit is contained in:
Mitchell Hashimoto 2017-01-26 20:12:01 -08:00
parent 6c266d6ce3
commit a561934f61
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 0 additions and 145 deletions

View File

@ -21,32 +21,6 @@ func (n *graphNodeExpandedResource) Name() string {
return fmt.Sprintf("%s #%d", n.Resource.Id(), n.Index) return fmt.Sprintf("%s #%d", n.Resource.Id(), n.Index)
} }
// GraphNodeAddressable impl.
func (n *graphNodeExpandedResource) ResourceAddress() *ResourceAddress {
// We want this to report the logical index properly, so we must undo the
// special case from the expand
index := n.Index
if index == -1 {
index = 0
}
return &ResourceAddress{
Path: n.Path[1:],
Index: index,
InstanceType: TypePrimary,
Name: n.Resource.Name,
Type: n.Resource.Type,
Mode: n.Resource.Mode,
}
}
// GraphNodeDependable impl.
func (n *graphNodeExpandedResource) DependableName() []string {
return []string{
n.Resource.Id(),
n.stateId(),
}
}
// GraphNodeDependent impl. // GraphNodeDependent impl.
func (n *graphNodeExpandedResource) DependentOn() []string { func (n *graphNodeExpandedResource) DependentOn() []string {
configNode := &GraphNodeConfigResource{Resource: n.Resource} configNode := &GraphNodeConfigResource{Resource: n.Resource}
@ -79,11 +53,6 @@ func (n *graphNodeExpandedResource) DependentOn() []string {
return result return result
} }
// GraphNodeProviderConsumer
func (n *graphNodeExpandedResource) ProvidedBy() []string {
return []string{resourceProvider(n.Resource.Type, n.Resource.Provider)}
}
func (n *graphNodeExpandedResource) StateDependencies() []string { func (n *graphNodeExpandedResource) StateDependencies() []string {
depsRaw := n.DependentOn() depsRaw := n.DependentOn()
deps := make([]string, 0, len(depsRaw)) deps := make([]string, 0, len(depsRaw))
@ -105,11 +74,6 @@ func (n *graphNodeExpandedResource) StateDependencies() []string {
return deps return deps
} }
// instanceInfo is used for EvalTree.
func (n *graphNodeExpandedResource) instanceInfo() *InstanceInfo {
return &InstanceInfo{Id: n.stateId(), Type: n.Resource.Type}
}
// stateId is the name used for the state key // stateId is the name used for the state key
func (n *graphNodeExpandedResource) stateId() string { func (n *graphNodeExpandedResource) stateId() string {
if n.Index == -1 { if n.Index == -1 {
@ -118,112 +82,3 @@ func (n *graphNodeExpandedResource) stateId() string {
return fmt.Sprintf("%s.%d", n.Resource.Id(), n.Index) return fmt.Sprintf("%s.%d", n.Resource.Id(), n.Index)
} }
// GraphNodeStateRepresentative impl.
func (n *graphNodeExpandedResource) StateId() []string {
return []string{n.stateId()}
}
// graphNodeExpandedResourceDestroy represents an expanded resource that
// is to be destroyed.
type graphNodeExpandedResourceDestroy struct {
*graphNodeExpandedResource
}
func (n *graphNodeExpandedResourceDestroy) Name() string {
return fmt.Sprintf("%s (destroy)", n.graphNodeExpandedResource.Name())
}
// GraphNodeEvalable impl.
func (n *graphNodeExpandedResourceDestroy) EvalTree() EvalNode {
info := n.instanceInfo()
info.uniqueExtra = "destroy"
var diffApply *InstanceDiff
var provider ResourceProvider
var state *InstanceState
var err error
return &EvalOpFilter{
Ops: []walkOperation{walkApply, walkDestroy},
Node: &EvalSequence{
Nodes: []EvalNode{
// Get the saved diff for apply
&EvalReadDiff{
Name: n.stateId(),
Diff: &diffApply,
},
// Filter the diff so we only get the destroy
&EvalFilterDiff{
Diff: &diffApply,
Output: &diffApply,
Destroy: true,
},
// If we're not destroying, then compare diffs
&EvalIf{
If: func(ctx EvalContext) (bool, error) {
if diffApply != nil && diffApply.GetDestroy() {
return true, nil
}
return true, EvalEarlyExitError{}
},
Then: EvalNoop{},
},
// Load the instance info so we have the module path set
&EvalInstanceInfo{Info: info},
&EvalGetProvider{
Name: n.ProvidedBy()[0],
Output: &provider,
},
&EvalReadState{
Name: n.stateId(),
Output: &state,
},
&EvalRequireState{
State: &state,
},
// Make sure we handle data sources properly.
&EvalIf{
If: func(ctx EvalContext) (bool, error) {
if n.Resource.Mode == config.DataResourceMode {
return true, nil
}
return false, nil
},
Then: &EvalReadDataApply{
Info: info,
Diff: &diffApply,
Provider: &provider,
Output: &state,
},
Else: &EvalApply{
Info: info,
State: &state,
Diff: &diffApply,
Provider: &provider,
Output: &state,
Error: &err,
},
},
&EvalWriteState{
Name: n.stateId(),
ResourceType: n.Resource.Type,
Provider: n.Resource.Provider,
Dependencies: n.StateDependencies(),
State: &state,
},
&EvalApplyPost{
Info: info,
State: &state,
Error: &err,
},
},
},
}
}