Update docs and add warning for -get-plugins
As of Terraform 0.13+, the get-plugins command has been superceded by new provider installation mechanisms, and general philosophy (providers are always installed, but the sources may be customized). Updat the init command to give users a warning if they are setting this flag, to encourage them to remove it from their workflow, and update relevant docs and docstrings as well
This commit is contained in:
parent
bedc08f5eb
commit
b963ea8594
|
@ -31,14 +31,11 @@ import (
|
||||||
// module and clones it to the working directory.
|
// module and clones it to the working directory.
|
||||||
type InitCommand struct {
|
type InitCommand struct {
|
||||||
Meta
|
Meta
|
||||||
|
|
||||||
// getPlugins is for the -get-plugins flag
|
|
||||||
getPlugins bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *InitCommand) Run(args []string) int {
|
func (c *InitCommand) Run(args []string) int {
|
||||||
var flagFromModule string
|
var flagFromModule string
|
||||||
var flagBackend, flagGet, flagUpgrade bool
|
var flagBackend, flagGet, flagUpgrade, getPlugins bool
|
||||||
var flagPluginPath FlagStringSlice
|
var flagPluginPath FlagStringSlice
|
||||||
var flagVerifyPlugins bool
|
var flagVerifyPlugins bool
|
||||||
flagConfigExtra := newRawFlags("-backend-config")
|
flagConfigExtra := newRawFlags("-backend-config")
|
||||||
|
@ -49,7 +46,7 @@ func (c *InitCommand) Run(args []string) int {
|
||||||
cmdFlags.Var(flagConfigExtra, "backend-config", "")
|
cmdFlags.Var(flagConfigExtra, "backend-config", "")
|
||||||
cmdFlags.StringVar(&flagFromModule, "from-module", "", "copy the source of the given module into the directory before init")
|
cmdFlags.StringVar(&flagFromModule, "from-module", "", "copy the source of the given module into the directory before init")
|
||||||
cmdFlags.BoolVar(&flagGet, "get", true, "")
|
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.forceInitCopy, "force-copy", false, "suppress prompts about copying state data")
|
||||||
cmdFlags.BoolVar(&c.Meta.stateLock, "lock", true, "lock state")
|
cmdFlags.BoolVar(&c.Meta.stateLock, "lock", true, "lock state")
|
||||||
cmdFlags.DurationVar(&c.Meta.stateLockTimeout, "lock-timeout", 0, "lock timeout")
|
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 {
|
if len(flagPluginPath) > 0 {
|
||||||
c.pluginPath = flagPluginPath
|
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
|
// Validate the arg count
|
||||||
|
@ -971,7 +977,6 @@ func (c *InitCommand) AutocompleteFlags() complete.Flags {
|
||||||
"-force-copy": complete.PredictNothing,
|
"-force-copy": complete.PredictNothing,
|
||||||
"-from-module": completePredictModuleSource,
|
"-from-module": completePredictModuleSource,
|
||||||
"-get": completePredictBoolean,
|
"-get": completePredictBoolean,
|
||||||
"-get-plugins": completePredictBoolean,
|
|
||||||
"-input": completePredictBoolean,
|
"-input": completePredictBoolean,
|
||||||
"-lock": completePredictBoolean,
|
"-lock": completePredictBoolean,
|
||||||
"-lock-timeout": complete.PredictAnything,
|
"-lock-timeout": complete.PredictAnything,
|
||||||
|
@ -1024,6 +1029,9 @@ Options:
|
||||||
-get=true Download any modules for this configuration.
|
-get=true Download any modules for this configuration.
|
||||||
|
|
||||||
-get-plugins=true Download any missing plugins 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=true Ask for input if necessary. If false, will error if
|
||||||
input was required.
|
input was required.
|
||||||
|
@ -1042,8 +1050,8 @@ Options:
|
||||||
-reconfigure Reconfigure the backend, ignoring any saved
|
-reconfigure Reconfigure the backend, ignoring any saved
|
||||||
configuration.
|
configuration.
|
||||||
|
|
||||||
-upgrade=false If installing modules (-get) or plugins (-get-plugins),
|
-upgrade=false If installing modules (-get) or plugins, ignore
|
||||||
ignore previously-downloaded objects and install the
|
previously-downloaded objects and install the
|
||||||
latest version allowed within configured constraints.
|
latest version allowed within configured constraints.
|
||||||
|
|
||||||
-verify-plugins=true Verify the authenticity and integrity of automatically
|
-verify-plugins=true Verify the authenticity and integrity of automatically
|
||||||
|
|
|
@ -226,7 +226,6 @@ func TestInit_getUpgradeModules(t *testing.T) {
|
||||||
|
|
||||||
args := []string{
|
args := []string{
|
||||||
"-get=true",
|
"-get=true",
|
||||||
"-get-plugins=false",
|
|
||||||
"-upgrade",
|
"-upgrade",
|
||||||
testFixturePath("init-get"),
|
testFixturePath("init-get"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
that version constraints within Terraform configurations do not exclude all
|
||||||
of the versions available from the bundle. If a suitable version cannot be
|
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
|
found in the bundle, Terraform _will_ attempt to satisfy that dependency by
|
||||||
automatic installation from the official repository. If you want
|
automatic installation from the official repository.
|
||||||
`terraform init` to explicitly fail instead of contacting the repository, pass
|
|
||||||
the `-get-plugins=false` option.
|
|
||||||
|
|
||||||
For full details about provider resolution, see
|
For full details about provider resolution, see
|
||||||
[How Terraform Works: Plugin Discovery](https://www.terraform.io/docs/extend/how-terraform-works.html#discovery).
|
[How Terraform Works: Plugin Discovery](https://www.terraform.io/docs/extend/how-terraform-works.html#discovery).
|
||||||
|
|
|
@ -142,11 +142,10 @@ You can modify `terraform init`'s plugin behavior with the following options:
|
||||||
cause Terraform to ignore any selections recorded in the dependency lock
|
cause Terraform to ignore any selections recorded in the dependency lock
|
||||||
file, and to take the newest available version matching the configured
|
file, and to take the newest available version matching the configured
|
||||||
version constraints.
|
version constraints.
|
||||||
- `-get-plugins=false` — Skip plugin installation. If you previously ran
|
- `-get-plugins=false` — Skip plugin installation. _Note: Since Terraform 0.13, this
|
||||||
`terraform init` without this option, the previously-installed plugins will
|
command has been superseded by [`provider_installation`](./cli-config.html#provider-installation)
|
||||||
remain available in your current working directory. If you have not
|
blocks or using the [`plugin_cache_dir`](./cli-config.html#plugin_cache_dir) setting.
|
||||||
previously run without this option, subsequent Terraform commands will
|
It should not be used in Terraform versions 0.13+.
|
||||||
fail due to the needed provider plugins being unavailable.
|
|
||||||
- `-plugin-dir=PATH` — Force plugin installation to read plugins _only_ from
|
- `-plugin-dir=PATH` — Force plugin installation to read plugins _only_ from
|
||||||
the specified directory, as if it had been configured as a `filesystem_mirror`
|
the specified directory, as if it had been configured as a `filesystem_mirror`
|
||||||
in the CLI configuration. If you intend to routinely use a particular
|
in the CLI configuration. If you intend to routinely use a particular
|
||||||
|
|
Loading…
Reference in New Issue