cli: Add -ignore-remote-version flag for init

When performing state migration to a remote backend target, Terraform
may fail due to mismatched remote and local Terraform versions. Here we
add the `-ignore-remote-version` flag to allow users to ignore this
version check when necessary.
This commit is contained in:
Alisdair McDiarmid 2021-06-02 15:30:05 -04:00
parent 6692336541
commit 3f0c6a2217
1 changed files with 33 additions and 29 deletions

View File

@ -49,6 +49,7 @@ func (c *InitCommand) Run(args []string) int {
cmdFlags.BoolVar(&flagUpgrade, "upgrade", false, "") cmdFlags.BoolVar(&flagUpgrade, "upgrade", false, "")
cmdFlags.Var(&flagPluginPath, "plugin-dir", "plugin directory") cmdFlags.Var(&flagPluginPath, "plugin-dir", "plugin directory")
cmdFlags.StringVar(&flagLockfile, "lockfile", "", "Set a dependency lockfile mode") cmdFlags.StringVar(&flagLockfile, "lockfile", "", "Set a dependency lockfile mode")
cmdFlags.BoolVar(&c.Meta.ignoreRemoteVersion, "ignore-remote-version", false, "continue even if remote and local Terraform versions are incompatible")
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) } cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
if err := cmdFlags.Parse(args); err != nil { if err := cmdFlags.Parse(args); err != nil {
return 1 return 1
@ -1003,6 +1004,9 @@ Options:
-lockfile=MODE Set a dependency lockfile mode. -lockfile=MODE Set a dependency lockfile mode.
Currently only "readonly" is valid. Currently only "readonly" is valid.
-ignore-remote-version A rare option used for the remote backend only. See
the remote backend documentation for more information.
` `
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }