core: Skip provider checksum validation based on env var
Skips checksum validation if the `TF_SKIP_PROVIDER_VERIFY` environment variable is set. Undocumented variable, as the primary goal is to significantly improve the local provider development workflow.
This commit is contained in:
parent
e6ddd62583
commit
9944ea6886
|
@ -206,6 +206,10 @@ func (c *InitCommand) Run(args []string) int {
|
|||
state = sMgr.State()
|
||||
}
|
||||
|
||||
if v := os.Getenv(ProviderSkipVerifyEnvVar); v != "" {
|
||||
c.ignorePluginChecksum = true
|
||||
}
|
||||
|
||||
// Now that we have loaded all modules, check the module tree for missing providers.
|
||||
err = c.getProviders(path, state, flagUpgrade)
|
||||
if err != nil {
|
||||
|
@ -330,6 +334,9 @@ func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade
|
|||
return err
|
||||
}
|
||||
digests[name] = digest
|
||||
if c.ignorePluginChecksum {
|
||||
digests[name] = nil
|
||||
}
|
||||
}
|
||||
err = c.providerPluginsLock().Write(digests)
|
||||
if err != nil {
|
||||
|
|
|
@ -51,9 +51,11 @@ type Meta struct {
|
|||
// pluginPath is a user defined set of directories to look for plugins.
|
||||
// This is set during init with the `-plugin-dir` flag, saved to a file in
|
||||
// the data directory.
|
||||
// This overrides all other search paths when discoverying plugins.
|
||||
// This overrides all other search paths when discovering plugins.
|
||||
pluginPath []string
|
||||
|
||||
ignorePluginChecksum bool
|
||||
|
||||
// Override certain behavior for tests within this package
|
||||
testingOverrides *testingOverrides
|
||||
|
||||
|
@ -224,6 +226,10 @@ func (m *Meta) StdinPiped() bool {
|
|||
return fi.Mode()&os.ModeNamedPipe != 0
|
||||
}
|
||||
|
||||
const (
|
||||
ProviderSkipVerifyEnvVar = "TF_SKIP_PROVIDER_VERIFY"
|
||||
)
|
||||
|
||||
// contextOpts returns the options to use to initialize a Terraform
|
||||
// context with the settings from this Meta.
|
||||
func (m *Meta) contextOpts() *terraform.ContextOpts {
|
||||
|
@ -260,6 +266,9 @@ func (m *Meta) contextOpts() *terraform.ContextOpts {
|
|||
}
|
||||
|
||||
opts.ProviderSHA256s = m.providerPluginsLock().Read()
|
||||
if v := os.Getenv(ProviderSkipVerifyEnvVar); v != "" {
|
||||
opts.SkipProviderVerify = true
|
||||
}
|
||||
|
||||
opts.Meta = &terraform.ContextMeta{
|
||||
Env: m.Workspace(),
|
||||
|
|
|
@ -65,7 +65,8 @@ type ContextOpts struct {
|
|||
|
||||
// If non-nil, will apply as additional constraints on the provider
|
||||
// plugins that will be requested from the provider resolver.
|
||||
ProviderSHA256s map[string][]byte
|
||||
ProviderSHA256s map[string][]byte
|
||||
SkipProviderVerify bool
|
||||
|
||||
UIInput UIInput
|
||||
}
|
||||
|
@ -185,7 +186,7 @@ func NewContext(opts *ContextOpts) (*Context, error) {
|
|||
var err error
|
||||
deps := ModuleTreeDependencies(opts.Module, state)
|
||||
reqd := deps.AllPluginRequirements()
|
||||
if opts.ProviderSHA256s != nil {
|
||||
if opts.ProviderSHA256s != nil && !opts.SkipProviderVerify {
|
||||
reqd.LockExecutables(opts.ProviderSHA256s)
|
||||
}
|
||||
providers, err = resourceProviderFactories(opts.ProviderResolver, reqd)
|
||||
|
|
Loading…
Reference in New Issue