terraform: add provisioner nodes to the apply graph
This commit is contained in:
parent
4033e90474
commit
0f0eecfee7
|
@ -59,6 +59,10 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer {
|
||||||
&ProviderTransformer{},
|
&ProviderTransformer{},
|
||||||
&ParentProviderTransformer{},
|
&ParentProviderTransformer{},
|
||||||
|
|
||||||
|
// Provisioner-related transformations
|
||||||
|
&MissingProvisionerTransformer{Provisioners: b.Provisioners},
|
||||||
|
&ProvisionerTransformer{},
|
||||||
|
|
||||||
// Attach the configurations
|
// Attach the configurations
|
||||||
&AttachConfigTransformer{Module: b.Module},
|
&AttachConfigTransformer{Module: b.Module},
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,10 @@ func TestApplyGraphBuilder(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
b := &ApplyGraphBuilder{
|
b := &ApplyGraphBuilder{
|
||||||
Diff: diff,
|
Module: testModule(t, "graph-builder-apply-basic"),
|
||||||
Providers: []string{"aws"},
|
Diff: diff,
|
||||||
|
Providers: []string{"aws"},
|
||||||
|
Provisioners: []string{"exec"},
|
||||||
}
|
}
|
||||||
|
|
||||||
g, err := b.Build(RootModulePath)
|
g, err := b.Build(RootModulePath)
|
||||||
|
@ -72,9 +74,11 @@ aws_instance.create
|
||||||
provider.aws
|
provider.aws
|
||||||
module.child.aws_instance.create
|
module.child.aws_instance.create
|
||||||
module.child.provider.aws
|
module.child.provider.aws
|
||||||
|
provisioner.exec
|
||||||
module.child.provider.aws
|
module.child.provider.aws
|
||||||
provider.aws
|
provider.aws
|
||||||
provider.aws
|
provider.aws
|
||||||
|
provisioner.exec
|
||||||
root
|
root
|
||||||
aws_instance.create
|
aws_instance.create
|
||||||
module.child.aws_instance.create
|
module.child.aws_instance.create
|
||||||
|
|
|
@ -39,6 +39,23 @@ func (n *NodeApplyableResource) ProvidedBy() []string {
|
||||||
return []string{resourceProvider(n.Addr.Type, "")}
|
return []string{resourceProvider(n.Addr.Type, "")}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GraphNodeProvisionerConsumer
|
||||||
|
func (n *NodeApplyableResource) ProvisionedBy() []string {
|
||||||
|
// If we have no configuration, then we have no provisioners
|
||||||
|
if n.Config == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build the list of provisioners we need based on the configuration.
|
||||||
|
// It is okay to have duplicates here.
|
||||||
|
result := make([]string, len(n.Config.Provisioners))
|
||||||
|
for i, p := range n.Config.Provisioners {
|
||||||
|
result[i] = p.Type
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
// GraphNodeEvalable
|
// GraphNodeEvalable
|
||||||
func (n *NodeApplyableResource) EvalTree() EvalNode {
|
func (n *NodeApplyableResource) EvalTree() EvalNode {
|
||||||
// stateId is the ID to put into the state
|
// stateId is the ID to put into the state
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
resource "aws_instance" "create" {
|
||||||
|
provisioner "exec" {}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
module "child" {
|
||||||
|
source = "./child"
|
||||||
|
}
|
Loading…
Reference in New Issue