hashicorp / terraform-provider-ignition

Terraform Ignition provider
https://www.terraform.io/docs/providers/ignition/
Mozilla Public License 2.0
39 stars 64 forks source link

Added nil check for empty lists in Ignition Config builders #7

Closed kenXengineering closed 7 years ago

kenXengineering commented 7 years ago

Added unit test for Ignition Config testing builders

If we pass an empty list down into any of the Ignition Config units (disk, raid, filesystem, file, systemd unit, networkd unit, user, group), the build function for the unit will panic as list will contain nill interfaces (for each empty list passed in).

I ran into this issue when I was creating modules to EC2 instances. I want the ability to pass down different ignition units so I can customize the instance when calling the module. To allow this I define variables as empty lists, so you are not required to pass a list down. However the config builder would panic as the empty lists were turned into nil []interfaces. Adding a nil check took care of it.

Signed-off-by: Ken Herner ken@astronomer.io

mcuadros commented 7 years ago

Nice! can you rebase @chosenken ?

kenXengineering commented 7 years ago

@mcuadros Just did the rebase, let me know if you need anything else, thanks!