command: Fix backend config override validation #25960
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When loading a backend config override file, init was doing two things wrong:
workspaces
block, which we need to support here.This commit fixes the first bug with an early return and adds test cases for missing file and intentionally-blank filename (to clear the config).
We also add a schema validation for the backend block, based on the backend schema itself. This requires constructing an HCL body schema so that we can call
Content
and check for diagnostic errors.The result is more useful errors when an invalid backend config override file is used, while also supporting the enhanced remote backend config fully.
Does not include tests specific to the remote backend, because the mocking involved to allow the backend to fully initialize is too involved to be worth it. Here's what that looks like: 159cdd3
Fixes #25793