terraform: input graph

This commit is contained in:
Mitchell Hashimoto 2017-01-23 21:48:22 -08:00
parent 7c014b84b6
commit 66f6f70cdb
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
3 changed files with 24 additions and 9 deletions

View File

@ -216,6 +216,9 @@ func (c *Context) Graph(typ GraphType, opts *ContextGraphOpts) (*Graph, error) {
Validate: opts.Validate,
}).Build(RootModulePath)
case GraphTypeInput:
// The input graph is just a slightly modified plan graph
fallthrough
case GraphTypePlan:
return (&PlanGraphBuilder{
Module: c.module,
@ -223,6 +226,7 @@ func (c *Context) Graph(typ GraphType, opts *ContextGraphOpts) (*Graph, error) {
Providers: c.components.ResourceProviders(),
Targets: c.targets,
Validate: opts.Validate,
Input: typ == GraphTypeInput,
}).Build(RootModulePath)
case GraphTypePlanDestroy:
@ -411,7 +415,7 @@ func (c *Context) Input(mode InputMode) error {
if mode&InputModeProvider != 0 {
// Build the graph
graph, err := c.Graph(GraphTypeLegacy, nil)
graph, err := c.Graph(GraphTypeInput, nil)
if err != nil {
return err
}

View File

@ -14,6 +14,7 @@ const (
GraphTypePlan
GraphTypePlanDestroy
GraphTypeApply
GraphTypeInput
)
// GraphTypeMap is a mapping of human-readable string to GraphType. This
@ -21,6 +22,7 @@ const (
// graph types.
var GraphTypeMap = map[string]GraphType{
"apply": GraphTypeApply,
"input": GraphTypeInput,
"plan": GraphTypePlan,
"plan-destroy": GraphTypePlanDestroy,
"refresh": GraphTypeRefresh,

View File

@ -34,6 +34,14 @@ type PlanGraphBuilder struct {
// Validate will do structural validation of the graph.
Validate bool
// Input, if true, modifies this graph for inputs. There isn't a
// dedicated input graph because asking for input is identical to
// planning except for the operations done. You still need to know WHAT
// you're going to plan since you only need to ask for input for things
// that are necessary for planning. This requirement makes the graphs
// very similar.
Input bool
}
// See GraphBuilder
@ -54,17 +62,18 @@ func (b *PlanGraphBuilder) Steps() []GraphTransformer {
}
}
concreteResource := func(a *NodeAbstractResource) dag.Vertex {
return &NodePlannableResource{
NodeAbstractCountResource: &NodeAbstractCountResource{
var concreteResource, concreteResourceOrphan ConcreteResourceNodeFunc
if !b.Input {
concreteResource = func(a *NodeAbstractResource) dag.Vertex {
return &NodePlannableResource{
NodeAbstractResource: a,
},
}
}
}
concreteResourceOrphan := func(a *NodeAbstractResource) dag.Vertex {
return &NodePlannableResourceOrphan{
NodeAbstractResource: a,
concreteResourceOrphan = func(a *NodeAbstractResource) dag.Vertex {
return &NodePlannableResourceOrphan{
NodeAbstractResource: a,
}
}
}