Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
template: add test with custom function on decode
When working on plugins' code, we noticed that in some cases functions could not be invoked when decoding a value in HCL2 templates. This is because in some plugins, the interpolation context is part of the configuration structure, and is also used for interpolating data in the SDK's Decode function, used to convert over-the-wire data (either in gob or cty format) into a flat representation of a final config, then to the config used by the component. During this step, we zero-out the final config object for HCL2 templates, as we call `Prepare` multiple times for some component types, typically provisioners and post-processors, and preparation may yield a final object that cannot re-pass validation. However, since the configuration object contains the interpolation context that is passed to `Decode`, it also gets zeroed-out, which causes any custom functions locally registered to the context to be lost, and therefore causing Decode to fail. We don't yet have a robust solution to this problem, but with this commit, we have a test that reliably reproduces the error so that we can later validate we have a fix to this.
- Loading branch information