mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
cli: Fix init failure with deleted cache
The init command needs to initialize a backend, in order to access state, in turn to derive provider requirements from state. The backend initialization step requires building provider factories, which previously would fail if a lockfile was present without a corresponding local provider cache. This commit ensures that in this situation only, errors with the provider factories are temporarily ignored. This allows us to continue to initialize the backend, fetch providers, and then report any errors as necessary.
This commit is contained in:
@@ -238,7 +238,7 @@ func (c *InitCommand) Run(args []string) int {
|
||||
// by a previous run, so we must still expect that "back" may be nil
|
||||
// in code that follows.
|
||||
var backDiags tfdiags.Diagnostics
|
||||
back, backDiags = c.Backend(nil)
|
||||
back, backDiags = c.Backend(&BackendOpts{Init: true})
|
||||
if backDiags.HasErrors() {
|
||||
// This is fine. We'll proceed with no backend, then.
|
||||
back = nil
|
||||
|
||||
Reference in New Issue
Block a user