Skip to content

Commit

Permalink
handle null evalContext (#883)
Browse files Browse the repository at this point in the history
if there is no evalcontext for the block, create a new one
  • Loading branch information
Owen Rumney committed Jul 15, 2021
1 parent b55a965 commit 001f0ec
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/app/tfsec/block/hclblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ func NewHCLBlock(hclBlock *hcl.Block, ctx *hcl.EvalContext, moduleBlock Block) B
}

func (block *HCLBlock) Clone(index int) Block {
childCtx := block.evalContext.Parent().NewChild()
var childCtx *hcl.EvalContext
if block.evalContext != nil {
childCtx = block.evalContext.NewChild()
} else {
childCtx = &hcl.EvalContext{}
}

if childCtx.Variables == nil {
childCtx.Variables = make(map[string]cty.Value)
}
Expand Down

0 comments on commit 001f0ec

Please sign in to comment.