You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PSS: Add reusable method for obtaining the provider factory needed for accessing a state store. (#37665)
* Add method to allow accessing factories from locks that are in memory
* Create new getStateStoreProviderFactory method for accessing a factory from config
* Update getStateStoreProviderFactory to use in memory locks instead of reading them from the deps lock file. Update calling code to accommodate this.
* Add tests for getStateStoreProviderFactory, improve errors returned from method
* Update test following schema change in simple providers
* Move test case into e2etest package, so we protect against environments where building binaries isn't possible
* Fix issues with running test in e2etest package
* Update code comments
Co-authored-by: Radek Simko <[email protected]>
---------
Co-authored-by: Radek Simko <[email protected]>
Detail: fmt.Sprintf("The provider %s (%q) is required to initialize the %q state store, but the matching provider factory is missing. This is a bug in Terraform and should be reported.",
// This may happen if the provider isn't present in the provider cache.
1771
+
// This should be caught earlier by logic that diffs the config against the backend state file.
1772
+
returnnil, diags.Append(&hcl.Diagnostic{
1773
+
Severity: hcl.DiagError,
1774
+
Summary: "Provider unavailable",
1775
+
Detail: fmt.Sprintf("Terraform experienced an error when trying to use provider %s (%q) to initialize the %q state store: %s",
1776
+
config.Provider.Name,
1777
+
config.ProviderAddr,
1778
+
config.Type,
1779
+
err),
1780
+
Subject: &config.TypeRange,
1781
+
})
1782
+
}
1783
+
1784
+
factory, exists:=factories[config.ProviderAddr]
1785
+
if!exists {
1786
+
returnnil, diags.Append(&hcl.Diagnostic{
1787
+
Severity: hcl.DiagError,
1788
+
Summary: "Provider unavailable",
1789
+
Detail: fmt.Sprintf("The provider %s (%q) is required to initialize the %q state store, but the matching provider factory is missing. This is a bug in Terraform and should be reported.",
expectedDetail:="Terraform experienced an error when trying to use provider foobar (\"registry.terraform.io/hashicorp/simple\") to initialize the \"store\" state store"
2439
+
ifdiags[0].Description().Summary!=expectedErr {
2440
+
t.Fatalf("expected error summary to include %q but got: %s",
0 commit comments