mirror of
https://github.com/hashicorp/terraform.git
synced 2026-02-18 18:29:44 -05:00
use pre-existing loaders where possible
This commit is contained in:
parent
4e921a8eae
commit
fd8d61ac9b
6 changed files with 7 additions and 50 deletions
|
|
@ -102,17 +102,10 @@ func (c *ApplyCommand) Run(rawArgs []string) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
loader, err := c.initConfigLoader()
|
||||
if err != nil {
|
||||
diags = diags.Append(err)
|
||||
view.Diagnostics(diags)
|
||||
return 1
|
||||
}
|
||||
|
||||
// Collect variable value and add them to the operation request
|
||||
var varDiags tfdiags.Diagnostics
|
||||
opReq.Variables, varDiags = args.Vars.CollectValues(func(filename string, src []byte) {
|
||||
loader.Parser().ForceFileSource(filename, src)
|
||||
opReq.ConfigLoader.Parser().ForceFileSource(filename, src)
|
||||
})
|
||||
diags = diags.Append(varDiags)
|
||||
|
||||
|
|
|
|||
|
|
@ -80,18 +80,10 @@ func (c *ConsoleCommand) Run(args []string) int {
|
|||
}
|
||||
|
||||
{
|
||||
|
||||
loader, err := c.initConfigLoader()
|
||||
if err != nil {
|
||||
diags = diags.Append(err)
|
||||
c.showDiagnostics(diags)
|
||||
return 1
|
||||
}
|
||||
|
||||
// Collect variable value and add them to the operation request
|
||||
var varDiags tfdiags.Diagnostics
|
||||
opReq.Variables, varDiags = parsedArgs.Vars.CollectValues(func(filename string, src []byte) {
|
||||
loader.Parser().ForceFileSource(filename, src)
|
||||
opReq.ConfigLoader.Parser().ForceFileSource(filename, src)
|
||||
})
|
||||
diags = diags.Append(varDiags)
|
||||
if varDiags.HasErrors() {
|
||||
|
|
|
|||
|
|
@ -179,19 +179,12 @@ func (c *ImportCommand) Run(args []string) int {
|
|||
return 1
|
||||
}
|
||||
opReq.Hooks = []terraform.Hook{c.uiHook()}
|
||||
|
||||
{
|
||||
|
||||
loader, err := c.initConfigLoader()
|
||||
if err != nil {
|
||||
diags = diags.Append(err)
|
||||
c.showDiagnostics(diags)
|
||||
return 1
|
||||
}
|
||||
|
||||
// Collect variable value and add them to the operation request
|
||||
var varDiags tfdiags.Diagnostics
|
||||
opReq.Variables, varDiags = parsedArgs.Vars.CollectValues(func(filename string, src []byte) {
|
||||
loader.Parser().ForceFileSource(filename, src)
|
||||
opReq.ConfigLoader.Parser().ForceFileSource(filename, src)
|
||||
})
|
||||
diags = diags.Append(varDiags)
|
||||
|
||||
|
|
|
|||
|
|
@ -86,17 +86,10 @@ func (c *PlanCommand) Run(rawArgs []string) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
loader, err := c.initConfigLoader()
|
||||
if err != nil {
|
||||
diags = diags.Append(err)
|
||||
view.Diagnostics(diags)
|
||||
return 1
|
||||
}
|
||||
|
||||
// Collect variable value and add them to the operation request
|
||||
var varDiags tfdiags.Diagnostics
|
||||
opReq.Variables, varDiags = args.Vars.CollectValues(func(filename string, src []byte) {
|
||||
loader.Parser().ForceFileSource(filename, src)
|
||||
opReq.ConfigLoader.Parser().ForceFileSource(filename, src)
|
||||
})
|
||||
diags = diags.Append(varDiags)
|
||||
|
||||
|
|
|
|||
|
|
@ -125,17 +125,10 @@ func (c *QueryCommand) Run(rawArgs []string) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
loader, err := c.initConfigLoader()
|
||||
if err != nil {
|
||||
diags = diags.Append(err)
|
||||
view.Diagnostics(diags)
|
||||
return 1
|
||||
}
|
||||
|
||||
// Collect variable value and add them to the operation request
|
||||
var varDiags tfdiags.Diagnostics
|
||||
opReq.Variables, varDiags = args.Vars.CollectValues(func(filename string, src []byte) {
|
||||
loader.Parser().ForceFileSource(filename, src)
|
||||
opReq.ConfigLoader.Parser().ForceFileSource(filename, src)
|
||||
})
|
||||
diags = diags.Append(varDiags)
|
||||
|
||||
|
|
|
|||
|
|
@ -82,17 +82,10 @@ func (c *RefreshCommand) Run(rawArgs []string) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
loader, err := c.initConfigLoader()
|
||||
if err != nil {
|
||||
diags = diags.Append(err)
|
||||
view.Diagnostics(diags)
|
||||
return 1
|
||||
}
|
||||
|
||||
// Collect variable value and add them to the operation request
|
||||
var varDiags tfdiags.Diagnostics
|
||||
opReq.Variables, varDiags = args.Vars.CollectValues(func(filename string, src []byte) {
|
||||
loader.Parser().ForceFileSource(filename, src)
|
||||
opReq.ConfigLoader.Parser().ForceFileSource(filename, src)
|
||||
})
|
||||
diags = diags.Append(varDiags)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue