]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/hashicorp/hcl2/hcl/static_expr.go
add contact_group resource to the provider
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / hcl2 / hcl / static_expr.go
CommitLineData
15c0b25d
AP
1package hcl
2
3import (
4 "github.com/zclconf/go-cty/cty"
5)
6
7type staticExpr struct {
8 val cty.Value
9 rng Range
10}
11
12// StaticExpr returns an Expression that always evaluates to the given value.
13//
14// This is useful to substitute default values for expressions that are
15// not explicitly given in configuration and thus would otherwise have no
16// Expression to return.
17//
18// Since expressions are expected to have a source range, the caller must
19// provide one. Ideally this should be a real source range, but it can
20// be a synthetic one (with an empty-string filename) if no suitable range
21// is available.
22func StaticExpr(val cty.Value, rng Range) Expression {
23 return staticExpr{val, rng}
24}
25
26func (e staticExpr) Value(ctx *EvalContext) (cty.Value, Diagnostics) {
27 return e.val, nil
28}
29
30func (e staticExpr) Variables() []Traversal {
31 return nil
32}
33
34func (e staticExpr) Range() Range {
35 return e.rng
36}
37
38func (e staticExpr) StartRange() Range {
39 return e.rng
40}