terraform: add provisioner nodes to the apply graph

This commit is contained in:
Mitchell Hashimoto 2016-09-15 09:32:37 -07:00
parent 4033e90474
commit 0f0eecfee7
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
5 changed files with 33 additions and 2 deletions

View File

@ -59,6 +59,10 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer {
&ProviderTransformer{},
&ParentProviderTransformer{},
// Provisioner-related transformations
&MissingProvisionerTransformer{Provisioners: b.Provisioners},
&ProvisionerTransformer{},
// Attach the configurations
&AttachConfigTransformer{Module: b.Module},

View File

@ -47,8 +47,10 @@ func TestApplyGraphBuilder(t *testing.T) {
}
b := &ApplyGraphBuilder{
Diff: diff,
Providers: []string{"aws"},
Module: testModule(t, "graph-builder-apply-basic"),
Diff: diff,
Providers: []string{"aws"},
Provisioners: []string{"exec"},
}
g, err := b.Build(RootModulePath)
@ -72,9 +74,11 @@ aws_instance.create
provider.aws
module.child.aws_instance.create
module.child.provider.aws
provisioner.exec
module.child.provider.aws
provider.aws
provider.aws
provisioner.exec
root
aws_instance.create
module.child.aws_instance.create

View File

@ -39,6 +39,23 @@ func (n *NodeApplyableResource) ProvidedBy() []string {
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
func (n *NodeApplyableResource) EvalTree() EvalNode {
// stateId is the ID to put into the state

View File

@ -0,0 +1,3 @@
resource "aws_instance" "create" {
provisioner "exec" {}
}

View File

@ -0,0 +1,3 @@
module "child" {
source = "./child"
}