Skip to content

Commit

Permalink
Merge pull request #108 from minamijoyo/revert-deprecation-of-plan-out
Browse files Browse the repository at this point in the history
Revert the deprecation of the tfmigrate plan --out=tfplan option
  • Loading branch information
minamijoyo authored Sep 14, 2022
2 parents 6bd3c21 + 310fd4e commit c8b54b8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,9 @@ Options:
key=value format backend configuraion.
This option is passed to terraform init when switching backend to remote.
[Deprecated]
--out=path Save a plan file after dry-run migration to the given path.
Note that applying the plan file only affects a local state,
make sure to force push it to remote after terraform apply.
This option doesn't work with Terraform 1.1+
Note that the saved plan file is not applicable in Terraform 1.1+.
It's intended to use only for static analysis.
```

```
Expand Down
14 changes: 3 additions & 11 deletions command/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (c *PlanCommand) Run(args []string) int {
cmdFlags := flag.NewFlagSet("plan", flag.ContinueOnError)
cmdFlags.StringVar(&c.configFile, "config", defaultConfigFile, "A path to tfmigrate config file")
cmdFlags.StringArrayVar(&c.backendConfig, "backend-config", nil, "A backend configuration for remote state")
cmdFlags.StringVar(&c.out, "out", "", "[Deprecated] Save a plan file after dry-run migration to the given path")
cmdFlags.StringVar(&c.out, "out", "", "Save a plan file after dry-run migration to the given path")

if err := cmdFlags.Parse(args); err != nil {
c.UI.Error(fmt.Sprintf("failed to parse arguments: %s", err))
Expand All @@ -43,12 +43,6 @@ func (c *PlanCommand) Run(args []string) int {
// So logging the option set log level to DEBUG instead of INFO.
log.Printf("[DEBUG] [command] option: %#v\n", c.Option)

// The tfmigrate plan --out=tfplan option is deprecated and doesn't work with Terraform 1.1+
// https://github.com/minamijoyo/tfmigrate/issues/62
if c.Option.PlanOut != "" {
log.Println("[WARN] The --out option is deprecated without replacement and it will be removed in a future release")
}

if c.config.History == nil {
// non-history mode
if len(cmdFlags.Args()) != 1 {
Expand Down Expand Up @@ -127,11 +121,9 @@ Options:
key=value format backend configuraion.
This option is passed to terraform init when switching backend to remote.
[Deprecated]
--out=path Save a plan file after dry-run migration to the given path.
Note that applying the plan file only affects a local state,
make sure to force push it to remote after terraform apply.
This option doesn't work with Terraform 1.1+
Note that the saved plan file is not applicable in Terraform 1.1+.
It's intended to use only for static analysis.
`
return strings.TrimSpace(helpText)
}
Expand Down
6 changes: 4 additions & 2 deletions tfmigrate/multi_state_migrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,10 @@ func TestAccMultiStateMigratorApply(t *testing.T) {
}

if tc.force {
// The tfmigrate plan --out=tfplan option is deprecated and doesn't work with Terraform 1.1+
// https://github.com/minamijoyo/tfmigrate/issues/62
// Note that the saved plan file is not applicable in Terraform 1.1+.
// https://github.com/minamijoyo/tfmigrate/pull/63
// It's intended to use only for static analysis.
// https://github.com/minamijoyo/tfmigrate/issues/106
fromTfVersionMatched, err := tfexec.MatchTerraformVersion(ctx, fromTf, ">= 1.1.0")
if err != nil {
t.Fatalf("failed to check terraform version constraints in fromDir: %s", err)
Expand Down
8 changes: 4 additions & 4 deletions tfmigrate/state_migrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ resource "aws_security_group" "baz" {}
t.Fatalf("expect to have changes")
}

// The tfmigrate plan --out=tfplan option was based on a bug prior to Terraform 1.1.
// Terraform v1.1 now rejects the plan as stale.
// The tfmigrate plan --out=tfplan option is deprecated without replacement.
// https://github.com/minamijoyo/tfmigrate/issues/62
// Note that the saved plan file is not applicable in Terraform 1.1+.
// https://github.com/minamijoyo/tfmigrate/pull/63
// It's intended to use only for static analysis.
// https://github.com/minamijoyo/tfmigrate/issues/106
tfVersionMatched, err := tfexec.MatchTerraformVersion(ctx, tf, ">= 1.1.0")
if err != nil {
t.Fatalf("failed to check terraform version constraints: %s", err)
Expand Down

0 comments on commit c8b54b8

Please sign in to comment.