diff --git a/command/init.go b/command/init.go index 392fb5e140..4507b33114 100644 --- a/command/init.go +++ b/command/init.go @@ -31,14 +31,11 @@ import ( // module and clones it to the working directory. type InitCommand struct { Meta - - // getPlugins is for the -get-plugins flag - getPlugins bool } func (c *InitCommand) Run(args []string) int { var flagFromModule string - var flagBackend, flagGet, flagUpgrade bool + var flagBackend, flagGet, flagUpgrade, getPlugins bool var flagPluginPath FlagStringSlice var flagVerifyPlugins bool flagConfigExtra := newRawFlags("-backend-config") @@ -49,7 +46,7 @@ func (c *InitCommand) Run(args []string) int { cmdFlags.Var(flagConfigExtra, "backend-config", "") cmdFlags.StringVar(&flagFromModule, "from-module", "", "copy the source of the given module into the directory before init") cmdFlags.BoolVar(&flagGet, "get", true, "") - cmdFlags.BoolVar(&c.getPlugins, "get-plugins", true, "") + cmdFlags.BoolVar(&getPlugins, "get-plugins", true, "no-op flag, use provider_installation blocks to customize provider installation") cmdFlags.BoolVar(&c.forceInitCopy, "force-copy", false, "suppress prompts about copying state data") cmdFlags.BoolVar(&c.Meta.stateLock, "lock", true, "lock state") cmdFlags.DurationVar(&c.Meta.stateLockTimeout, "lock-timeout", 0, "lock timeout") @@ -66,7 +63,16 @@ func (c *InitCommand) Run(args []string) int { if len(flagPluginPath) > 0 { c.pluginPath = flagPluginPath - c.getPlugins = false + } + + // If users are setting the no-op get-plugins command, give them a warning, + // this should allow us to remove the flag in the future. + if !getPlugins { + diags = diags.Append(tfdiags.Sourceless( + tfdiags.Warning, + "No-op -get-plugins flag used", + `As of Terraform 0.13+, the -get-plugins=false command is a no-op flag. If you would like to customize provider installation, use a provider_installation block or other available Terraform settings.`, + )) } // Validate the arg count @@ -993,7 +999,6 @@ func (c *InitCommand) AutocompleteFlags() complete.Flags { "-force-copy": complete.PredictNothing, "-from-module": completePredictModuleSource, "-get": completePredictBoolean, - "-get-plugins": completePredictBoolean, "-input": completePredictBoolean, "-lock": completePredictBoolean, "-lock-timeout": complete.PredictAnything, @@ -1046,6 +1051,9 @@ Options: -get=true Download any modules for this configuration. -get-plugins=true Download any missing plugins for this configuration. + This command is a no-op in Terraform 0.13+: use + -plugin-dir settings or provider_installation blocks + instead. -input=true Ask for input if necessary. If false, will error if input was required. @@ -1064,8 +1072,8 @@ Options: -reconfigure Reconfigure the backend, ignoring any saved configuration. - -upgrade=false If installing modules (-get) or plugins (-get-plugins), - ignore previously-downloaded objects and install the + -upgrade=false If installing modules (-get) or plugins, ignore + previously-downloaded objects and install the latest version allowed within configured constraints. -verify-plugins=true Verify the authenticity and integrity of automatically diff --git a/command/init_test.go b/command/init_test.go index 1eb5b8aef6..9f0005d938 100644 --- a/command/init_test.go +++ b/command/init_test.go @@ -226,7 +226,6 @@ func TestInit_getUpgradeModules(t *testing.T) { args := []string{ "-get=true", - "-get-plugins=false", "-upgrade", testFixturePath("init-get"), } diff --git a/tools/terraform-bundle/README.md b/tools/terraform-bundle/README.md index 916b33c1df..a19ca6afe1 100644 --- a/tools/terraform-bundle/README.md +++ b/tools/terraform-bundle/README.md @@ -171,9 +171,7 @@ Therefore if automatic installation is not desired, it is important to ensure that version constraints within Terraform configurations do not exclude all of the versions available from the bundle. If a suitable version cannot be found in the bundle, Terraform _will_ attempt to satisfy that dependency by -automatic installation from the official repository. If you want -`terraform init` to explicitly fail instead of contacting the repository, pass -the `-get-plugins=false` option. +automatic installation from the official repository. For full details about provider resolution, see [How Terraform Works: Plugin Discovery](https://www.terraform.io/docs/extend/how-terraform-works.html#discovery). diff --git a/website/docs/commands/init.html.markdown b/website/docs/commands/init.html.markdown index 3d2e5485f1..9f334cd8d5 100644 --- a/website/docs/commands/init.html.markdown +++ b/website/docs/commands/init.html.markdown @@ -140,15 +140,12 @@ You can modify `terraform init`'s plugin behavior with the following options: - `-upgrade` — Update all previously installed plugins to the newest version that complies with the configuration's version constraints. This option does not apply to manually installed plugins. -- `-get-plugins=false` — Skips plugin installation. Terraform will use plugins - installed in the user plugins directory, and any plugins already installed - for the current working directory. If the installed plugins aren't sufficient - for the configuration, init fails. -- `-plugin-dir=PATH` — Skips plugin installation and loads plugins _only_ from - the specified directory. This ignores the user plugins directory and any - plugins already installed in the current working directory. To restore the - default behavior after using this option, run init again and pass an empty - string to `-plugin-dir`. +- `-get-plugins=false` — Skip plugin installation. _Note: Since Terraform 0.13, this + command has been superseded by [`provider_installation`](./cli-config.html#provider-installation) +- `-plugin-dir=PATH` — Loads plugins _only_ from the specified directory. This + ignores the user plugins directory and any plugins already installed in the + current working directory. To restore the default behavior after using this option, + run init again and pass an empty string to `-plugin-dir`. - `-verify-plugins=false` — Skips release signature validation when installing downloaded plugins (not recommended). Official plugin releases are digitally signed by HashiCorp, and Terraform verifies these signatures when