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