Set packer_http_addr of extra-vars as an empty string when it's nil#174
Conversation
Signed-off-by: Connor Yan <126ium@126ium.moe>
lbajolet-hashicorp
left a comment
There was a problem hiding this comment.
Hi @126ium,
Thanks for the PR!
I just left one comment regarding the usage of the option, I think that if it is unset, it is probably better to not include it in the extra args instead of leaving it empty, but that could be a valid use though, I'll let you tell me what you think.
Aside from that, it looks good to me, we can merge this once we've reached a decision on this.
Thanks again!
|
|
||
| packerHTTPAddr := p.generatedData["PackerHTTPAddr"] | ||
| if packerHTTPAddr == nil { | ||
| packerHTTPAddr = "" |
There was a problem hiding this comment.
I would suggest maybe not adding the value to the extra-vars instead?
Unless this is used in the target, but then I would assume that it being empty would probably yield an error, so it may or may not be a good idea, what do you think?
There was a problem hiding this comment.
Thanks for your reply and suggestion. Your idea is better. The ansible-playbook already provides a good handler for empty/default extra-vars, so I believe there will be no potential error. It's unnecessary to add them explicitly when they are empty.
I'm testing new codes with my module. Then I'll update this patch once I get any updates.
Fixes #173. This fix involves examining the
generatedDatato determine if thePackerHTTPAddris nil. If thePackerHTTPAddris nil, set it as an empty string. This modification ensures the proper handling of the packer_http_addr variable within the ansible-local provisioner.Test
packer_http_addrshould be an empty string, not%!s(<nil>).Closes #173