aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/hcl2/hcl/static_expr.go
diff options
context:
space:
mode:
authorAlex Pilon <apilon@hashicorp.com>2019-02-22 18:24:37 -0500
committerAlex Pilon <apilon@hashicorp.com>2019-02-22 18:24:37 -0500
commit15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch)
tree255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/hashicorp/hcl2/hcl/static_expr.go
parent07971ca38143c5faf951d152fba370ddcbe26ad5 (diff)
downloadterraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz
terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst
terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2/hcl/static_expr.go')
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcl/static_expr.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/static_expr.go b/vendor/github.com/hashicorp/hcl2/hcl/static_expr.go
new file mode 100644
index 0000000..98ada87
--- /dev/null
+++ b/vendor/github.com/hashicorp/hcl2/hcl/static_expr.go
@@ -0,0 +1,40 @@
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}