mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
terrform: Thread provisioner factory through Context
This commit is contained in:
parent
ee475e8178
commit
87c3423fd4
@ -22,12 +22,13 @@ type genericWalkFunc func(*Resource) error
|
||||
//
|
||||
// Additionally, a context can be created from a Plan using Plan.Context.
|
||||
type Context struct {
|
||||
config *config.Config
|
||||
diff *Diff
|
||||
hooks []Hook
|
||||
state *State
|
||||
providers map[string]ResourceProviderFactory
|
||||
variables map[string]string
|
||||
config *config.Config
|
||||
diff *Diff
|
||||
hooks []Hook
|
||||
state *State
|
||||
providers map[string]ResourceProviderFactory
|
||||
provisioners map[string]ResourceProvisionerFactory
|
||||
variables map[string]string
|
||||
|
||||
l sync.Mutex // Lock acquired during any task
|
||||
parCh chan struct{} // Semaphore used to limit parallelism
|
||||
@ -39,13 +40,14 @@ type Context struct {
|
||||
// ContextOpts are the user-creatable configuration structure to create
|
||||
// a context with NewContext.
|
||||
type ContextOpts struct {
|
||||
Config *config.Config
|
||||
Diff *Diff
|
||||
Hooks []Hook
|
||||
Parallelism int
|
||||
State *State
|
||||
Providers map[string]ResourceProviderFactory
|
||||
Variables map[string]string
|
||||
Config *config.Config
|
||||
Diff *Diff
|
||||
Hooks []Hook
|
||||
Parallelism int
|
||||
State *State
|
||||
Providers map[string]ResourceProviderFactory
|
||||
Provisioners map[string]ResourceProvisionerFactory
|
||||
Variables map[string]string
|
||||
}
|
||||
|
||||
// NewContext creates a new context.
|
||||
@ -70,12 +72,13 @@ func NewContext(opts *ContextOpts) *Context {
|
||||
parCh := make(chan struct{}, par)
|
||||
|
||||
return &Context{
|
||||
config: opts.Config,
|
||||
diff: opts.Diff,
|
||||
hooks: hooks,
|
||||
state: opts.State,
|
||||
providers: opts.Providers,
|
||||
variables: opts.Variables,
|
||||
config: opts.Config,
|
||||
diff: opts.Diff,
|
||||
hooks: hooks,
|
||||
state: opts.State,
|
||||
providers: opts.Providers,
|
||||
provisioners: opts.Provisioners,
|
||||
variables: opts.Variables,
|
||||
|
||||
parCh: parCh,
|
||||
sh: sh,
|
||||
@ -92,10 +95,11 @@ func (c *Context) Apply() (*State, error) {
|
||||
defer c.releaseRun(v)
|
||||
|
||||
g, err := Graph(&GraphOpts{
|
||||
Config: c.config,
|
||||
Diff: c.diff,
|
||||
Providers: c.providers,
|
||||
State: c.state,
|
||||
Config: c.config,
|
||||
Diff: c.diff,
|
||||
Providers: c.providers,
|
||||
Provisioners: c.provisioners,
|
||||
State: c.state,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -135,9 +139,10 @@ func (c *Context) Plan(opts *PlanOpts) (*Plan, error) {
|
||||
defer c.releaseRun(v)
|
||||
|
||||
g, err := Graph(&GraphOpts{
|
||||
Config: c.config,
|
||||
Providers: c.providers,
|
||||
State: c.state,
|
||||
Config: c.config,
|
||||
Providers: c.providers,
|
||||
Provisioners: c.provisioners,
|
||||
State: c.state,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -188,9 +193,10 @@ func (c *Context) Refresh() (*State, error) {
|
||||
defer c.releaseRun(v)
|
||||
|
||||
g, err := Graph(&GraphOpts{
|
||||
Config: c.config,
|
||||
Providers: c.providers,
|
||||
State: c.state,
|
||||
Config: c.config,
|
||||
Providers: c.providers,
|
||||
Provisioners: c.provisioners,
|
||||
State: c.state,
|
||||
})
|
||||
if err != nil {
|
||||
return c.state, err
|
||||
@ -384,10 +390,11 @@ func (c *Context) computeResourceMultiVariable(
|
||||
|
||||
func (c *Context) graph() (*depgraph.Graph, error) {
|
||||
return Graph(&GraphOpts{
|
||||
Config: c.config,
|
||||
Diff: c.diff,
|
||||
Providers: c.providers,
|
||||
State: c.state,
|
||||
Config: c.config,
|
||||
Diff: c.diff,
|
||||
Providers: c.providers,
|
||||
Provisioners: c.provisioners,
|
||||
State: c.state,
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user