Skip to content

Commit

Permalink
Rename OverrideBackendToRemote to OverrideBackendToLocal
Browse files Browse the repository at this point in the history
  • Loading branch information
minamijoyo committed Aug 9, 2020
1 parent 152204d commit f3e8c89
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions tfexec/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ type TerraformCLI interface {
// It's intended to inject a wrapper command such as direnv.
SetExecPath(execPath string)

// OverrideBackendToRemote switches the backend to local and returns a function
// OverrideBackendToLocal switches the backend to local and returns a function
// for swtich back it to remote with defer.
// The -state flag for terraform command is not valid for remote state,
// so we need to switch the backend to local for temporary state operations.
// The filename argument must meet constraints for override file.
// (e.g.) _tfexec_override.tf
OverrideBackendToRemote(ctx context.Context, filename string) (func(), error)
OverrideBackendToLocal(ctx context.Context, filename string) (func(), error)

// PlanHasChange is a helper method which runs plan and return true if the plan has change.
PlanHasChange(ctx context.Context, state *State, dir string, opts ...string) (bool, error)
Expand Down Expand Up @@ -182,13 +182,13 @@ func (c *terraformCLI) SetExecPath(execPath string) {
c.execPath = execPath
}

// OverrideBackendToRemote switches the backend to local and returns a function
// OverrideBackendToLocal switches the backend to local and returns a function
// for swtich back it to remote with defer.
// The -state flag for terraform command is not valid for remote state,
// so we need to switch the backend to local for temporary state operations.
// The filename argument must meet constraints for override file.
// (e.g.) _tfexec_override.tf
func (c *terraformCLI) OverrideBackendToRemote(ctx context.Context, filename string) (func(), error) {
func (c *terraformCLI) OverrideBackendToLocal(ctx context.Context, filename string) (func(), error) {
// create local backend override file.
path := filepath.Join(c.Dir(), filename)
contents := `
Expand Down
6 changes: 3 additions & 3 deletions tfexec/terraform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestTerraformCLIRun(t *testing.T) {
}
}

func TestAccTerraformCLIOverrideBackendToRemote(t *testing.T) {
func TestAccTerraformCLIOverrideBackendToLocal(t *testing.T) {
SkipUnlessAcceptanceTestEnabled(t)

backend := GetTestAccBackendS3Config(t)
Expand Down Expand Up @@ -125,9 +125,9 @@ resource "aws_security_group" "bar" {}
t.Fatalf("an override file already exists: %s", err)
}

switchBackToRemotekFunc, err := terraformCLI.OverrideBackendToRemote(context.Background(), filename)
switchBackToRemotekFunc, err := terraformCLI.OverrideBackendToLocal(context.Background(), filename)
if err != nil {
t.Fatalf("failed to run OverrideBackendToRemote: %s", err)
t.Fatalf("failed to run OverrideBackendToLocal: %s", err)
}

if _, err := os.Stat(filepath.Join(terraformCLI.Dir(), filename)); os.IsNotExist(err) {
Expand Down
2 changes: 1 addition & 1 deletion tfmigrate/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func setupWorkDir(ctx context.Context, tf tfexec.TerraformCLI) (*tfexec.State, f

// The -state flag for terraform command is not valid for remote state,
// so we need to switch the backend to local for temporary state operations.
switchBackToRemotekFunc, err := tf.OverrideBackendToRemote(ctx, "_tfmigrate_override.tf")
switchBackToRemotekFunc, err := tf.OverrideBackendToLocal(ctx, "_tfmigrate_override.tf")
if err != nil {
return nil, nil, err
}
Expand Down

0 comments on commit f3e8c89

Please sign in to comment.