Merge pull request #25233 from hashicorp/alisdair/remove-implicit-init-then-apply

command/apply: Remove implicit init call
This commit is contained in:
Alisdair McDiarmid 2020-06-12 15:52:06 -04:00 committed by GitHub
commit 7d4cab126f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 32 deletions

View File

@ -3,11 +3,9 @@ package command
import (
"bytes"
"fmt"
"os"
"sort"
"strings"
"github.com/hashicorp/go-getter"
"github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/backend"
"github.com/hashicorp/terraform/configs/hcl2shim"
@ -53,11 +51,7 @@ func (c *ApplyCommand) Run(args []string) int {
var diags tfdiags.Diagnostics
// Get the args. The "maybeInit" flag tracks whether we may need to
// initialize the configuration from a remote path. This is true as long
// as we have an argument.
args = cmdFlags.Args()
maybeInit := len(args) == 1
configPath, err := ModulePath(args)
if err != nil {
c.Ui.Error(err.Error())
@ -70,32 +64,6 @@ func (c *ApplyCommand) Run(args []string) int {
return 1
}
if !c.Destroy && maybeInit {
// We need the pwd for the getter operation below
pwd, err := os.Getwd()
if err != nil {
c.Ui.Error(fmt.Sprintf("Error getting pwd: %s", err))
return 1
}
// Do a detect to determine if we need to do an init + apply.
if detected, err := getter.Detect(configPath, pwd, getter.Detectors); err != nil {
c.Ui.Error(fmt.Sprintf("Invalid path: %s", err))
return 1
} else if !strings.HasPrefix(detected, "file") {
// If this isn't a file URL then we're doing an init +
// apply.
var init InitCommand
init.Meta = c.Meta
if code := init.Run([]string{detected}); code != 0 {
return code
}
// Change the config path to be the cwd
configPath = pwd
}
}
// Check if the path is a plan
planFile, err := c.PlanFile(configPath)
if err != nil {