github.com/hashicorp/hcl/v2@v2.20.0/ext/dynblock/options.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package dynblock
     5  
     6  import (
     7  	"github.com/hashicorp/hcl/v2"
     8  	"github.com/zclconf/go-cty/cty"
     9  )
    10  
    11  type ExpandOption interface {
    12  	applyExpandOption(*expandBody)
    13  }
    14  
    15  type optCheckForEach struct {
    16  	check func(cty.Value, hcl.Expression, *hcl.EvalContext) hcl.Diagnostics
    17  }
    18  
    19  func OptCheckForEach(check func(cty.Value, hcl.Expression, *hcl.EvalContext) hcl.Diagnostics) ExpandOption {
    20  	return optCheckForEach{check}
    21  }
    22  
    23  // applyExpandOption implements ExpandOption.
    24  func (o optCheckForEach) applyExpandOption(body *expandBody) {
    25  	body.checkForEach = append(body.checkForEach, o.check)
    26  }