Skip to content

Commit

Permalink
type assertion check for hcl.Body (#832)
Browse files Browse the repository at this point in the history
  • Loading branch information
patilpankaj212 committed Jun 2, 2021
1 parent 358fc67 commit dec6618
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/iac-providers/terraform/commons/resource.go
Expand Up @@ -39,7 +39,11 @@ func CreateResourceConfig(managedResource *hclConfigs.Resource) (resourceConfig

// convert resource config from hcl.Body to map[string]interface{}
c := converter{bytes: fileBytes}
hclBody := managedResource.Config.(*hclsyntax.Body)
var hclBody *hclsyntax.Body
var ok bool
if hclBody, ok = managedResource.Config.(*hclsyntax.Body); !ok {
return resourceConfig, fmt.Errorf("failed type assertion for hcl.Body in *hclConfigs.Resource. error: expected hcl.Body type is *hclsyntax.Body, but got %T", managedResource.Config)
}
goOut, err := c.convertBody(hclBody)
if err != nil {
zap.S().Errorf("failed to convert hcl.Body to go struct; resource '%s', file: '%s'. error: '%v'",
Expand Down

0 comments on commit dec6618

Please sign in to comment.