Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: panic and crash when
size
parameter of a disk
is not parseab…
…le into a `Quantity` (#111) * Fix crash if disk size is not given Fix crash if the disk block in the virtualmachine resource does not contain a `size` parameter and also doesn't contain either of the `existing_volume_name` or the `container_image_name` parameters. The Terraform provider relied on the `builder` package always behaving nicely, but the `builder` package relied on all users checking inputs before and only giving valid inputs. Therefore error handling in case a non-parsable size has been given for a disk was not done, causing a crash. The size parameter is not mandatory in all cases and defaults to an empty string, which is not parsable into a `resource.Quantity` object. The fix here is to differentiate better when the `size` parameter is taken into account at all. In case it is not taken into account, it is completely ignored. If it is taken into account, a check is performed that ensures it's parsable. If it isn't parsable, the Terraform provider will return an error directly, indicating to the user where the problem is. related-to: harvester/harvester#7139 Signed-off-by: Moritz Röhrich <[email protected]> * Tests: Parseable `size` Parameter Add test to ensure that a non-parseable `size` parameter in a `disk` subresource of a `virtualmachine` resource generates an appropriate error message. The `size` parameter is not mandatory in all configurations, but when it is, it must be a parseable `resource.Quantity`, otherwise a panic and crash would ensue. Signed-off-by: Moritz Röhrich <[email protected]> --------- Signed-off-by: Moritz Röhrich <[email protected]>
- Loading branch information