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 stateStoreInitFromConfig method to Meta (#37723)
* Add SetStateStoreChunkSize to the mock provider for tests
* Implement configurable state chunk size
* Add chunk size negotiation to `savedStateStore`, update happy path test to assert it's set
* Update `savedStateStore` to return diagnostic if a nil factory is passed in, add unhappy path tests
* Add test coverage for stateStoreConfig, including use of config overrides with state stores
* Add godoc comment for backendInitFromConfig
* Avoid nil error in stateStoreConfig when there's no provider factory
* Add stateStoreInitFromConfig method and test coverage
* Refactor stateStoreInitFromConfig to accept factory directly, instead of accepting all BackendOpts
This is to avoid confusion, e.g. unnecessary duplication of config being passed in.
* Implement configurable state chunk size
* Remove TODO which has since been addressed
* Update happy path test for `stateStoreInitFromConfig` to check that chunk size is negotiated
* Update chunk size negotiation code in `stateStoreInitFromConfig` to error if the provider doesn't return a chunk size > 0
* Fix test error message
---------
Co-authored-by: Radek Simko <[email protected]>
// Check - is the state store type in the config supported by the provider?
570
+
ifopts.ProviderFactory==nil {
571
+
diags=diags.Append(&hcl.Diagnostic{
572
+
Severity: hcl.DiagError,
573
+
Summary: "Missing provider details when configuring state store",
574
+
Detail: "Terraform attempted to configure a state store and no provider factory was available to launch it. This is a bug in Terraform and should be reported.",
575
+
})
576
+
returnnil, 0, 0, diags
577
+
}
570
578
provider, err:=opts.ProviderFactory()
571
579
iferr!=nil {
572
580
diags=diags.Append(fmt.Errorf("error when obtaining provider instance during state store initialization: %w", err))
Summary: "Missing provider details when configuring state store",
1864
+
Detail: "Terraform attempted to configure a state store and no provider factory was available to launch it. This is a bug in Terraform and should be reported.",
1865
+
})
1866
+
returnnil, cty.NilVal, cty.NilVal, diags
1867
+
}
1868
+
provider, err:=factory()
1869
+
iferr!=nil {
1870
+
diags=diags.Append(fmt.Errorf("error when obtaining provider instance during state store initialization: %w", err))
1871
+
returnnil, cty.NilVal, cty.NilVal, diags
1872
+
}
1873
+
// We purposefully don't have a deferred call to the provider's Close method here because the calling code needs a
1874
+
// running provider instance inside the returned backend.Backend instance.
1875
+
// Stopping the provider process is the responsibility of the calling code.
1876
+
1877
+
resp:=provider.GetProviderSchema()
1878
+
1879
+
iflen(resp.StateStores) ==0 {
1880
+
diags=diags.Append(&hcl.Diagnostic{
1881
+
Severity: hcl.DiagError,
1882
+
Summary: "Provider does not support pluggable state storage",
1883
+
Detail: fmt.Sprintf("There are no state stores implemented by provider %s (%q)",
0 commit comments