Fix parse configuration's use of abstract filesystems #395
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.
This PR fixes two issues:
A test for the bump logic was using
assert.NoError
instead ofrequire.NoError
, so it panicked when the test proceeded to use a nil object after an error case.ParseConfiguration
wasn't correctly handling abstract filesystems. In general, when using anfs.FS
, the code should be able to trust that the config file path is meant for that filesystem, but it was usingfilepath.Base
in anticipation of receiving an absolute filepath for the actual OS filesystem. This PR detects if the caller is setting their ownfs.FS
and uses the given path "as-is" if so. In the future, we should adjustParseConfiguration
to always use a providedfs.FS
and thus always trust that the given config path is correct as-is.These issues were caught via tests in
wolfictl
.