terraform: input graph
This commit is contained in:
parent
7c014b84b6
commit
66f6f70cdb
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue