Skip to content

Commit 7d4cab1

Browse files
authored
Merge pull request #25233 from hashicorp/alisdair/remove-implicit-init-then-apply
command/apply: Remove implicit init call
2 parents b611bd7 + 0d614a8 commit 7d4cab1

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

command/apply.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ package command
33
import (
44
"bytes"
55
"fmt"
6-
"os"
76
"sort"
87
"strings"
98

10-
"github.com/hashicorp/go-getter"
119
"github.com/hashicorp/terraform/addrs"
1210
"github.com/hashicorp/terraform/backend"
1311
"github.com/hashicorp/terraform/configs/hcl2shim"
@@ -53,11 +51,7 @@ func (c *ApplyCommand) Run(args []string) int {
5351

5452
var diags tfdiags.Diagnostics
5553

56-
// Get the args. The "maybeInit" flag tracks whether we may need to
57-
// initialize the configuration from a remote path. This is true as long
58-
// as we have an argument.
5954
args = cmdFlags.Args()
60-
maybeInit := len(args) == 1
6155
configPath, err := ModulePath(args)
6256
if err != nil {
6357
c.Ui.Error(err.Error())
@@ -70,32 +64,6 @@ func (c *ApplyCommand) Run(args []string) int {
7064
return 1
7165
}
7266

73-
if !c.Destroy && maybeInit {
74-
// We need the pwd for the getter operation below
75-
pwd, err := os.Getwd()
76-
if err != nil {
77-
c.Ui.Error(fmt.Sprintf("Error getting pwd: %s", err))
78-
return 1
79-
}
80-
81-
// Do a detect to determine if we need to do an init + apply.
82-
if detected, err := getter.Detect(configPath, pwd, getter.Detectors); err != nil {
83-
c.Ui.Error(fmt.Sprintf("Invalid path: %s", err))
84-
return 1
85-
} else if !strings.HasPrefix(detected, "file") {
86-
// If this isn't a file URL then we're doing an init +
87-
// apply.
88-
var init InitCommand
89-
init.Meta = c.Meta
90-
if code := init.Run([]string{detected}); code != 0 {
91-
return code
92-
}
93-
94-
// Change the config path to be the cwd
95-
configPath = pwd
96-
}
97-
}
98-
9967
// Check if the path is a plan
10068
planFile, err := c.PlanFile(configPath)
10169
if err != nil {

0 commit comments

Comments
 (0)