hcl2template: only iterate on known HCP datasource (#11883)
hcl2template: only iterate on known HCP datasource (#11883)

When we try to validate a build that contains references to
hcp_packer_image, the data is not fetched, and the value is therefore
unknown.

However, during the decoding phase for the build blocks, we attempt to
fetch the ancestry information for the current build, from the
information previously fetched from HCP.

Since we're validating, there's no way this is set, and attempting to
cast without checking causes Packer to crash on the conversion.

To avoid this, we only attempt this conversion if the value is known.

Closes #11870
hashicorp/packer,hashicorp/packer,hashicorp/packer,hashicorp/packer