Fix undefined method '[]' for nil:NilClass
when creating filesystem…
#254
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.
The
filesystem
resource of this module is useful for creating filesystems even outside of the LVM.When we want to create a filesystem on a partition not created by LVM, the
filesystem
resource fails with the following error:The current code only catches non zero return codes from
blkid
when checking on logical volumes. On LVM volumes with no filesystem, theblkid
fails with return code 2 and that is catched and the functionfstype
returnsnil
But when we want to apply it to a partition that was not created by LVM that does not have filesystem yet, the
blkid
run succeeds, but the output is not as expected by this module. It misses theTYPE=" "
part.Example:
partition without FS
partition with fs
When it happens, the pattern matching does not find the
TYPE
and the result isnil
. Therefore it fails with the above mentioned error.This PR introduces a fix that checks the value before trying to use the
[1]
indexing. IfTYPE
was not found, it returnsnil
, as before.Thanks for the good work on the LVM module :)