Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions command/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand All @@ -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 {
Expand Down