terraform-provider-gitea/vendor/github.com/hashicorp/hcl/v2/static_expr.go
dependabot[bot] 84c9110a24
Bump github.com/hashicorp/terraform-plugin-sdk/v2 from 2.24.1 to 2.26.0
Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.24.1 to 2.26.0.
- [Release notes](https://github.com/hashicorp/terraform-plugin-sdk/releases)
- [Changelog](https://github.com/hashicorp/terraform-plugin-sdk/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/terraform-plugin-sdk/compare/v2.24.1...v2.26.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-plugin-sdk/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-20 20:25:53 +00:00

44 lines
1.0 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package hcl
import (
"github.com/zclconf/go-cty/cty"
)
type staticExpr struct {
val cty.Value
rng Range
}
// StaticExpr returns an Expression that always evaluates to the given value.
//
// This is useful to substitute default values for expressions that are
// not explicitly given in configuration and thus would otherwise have no
// Expression to return.
//
// Since expressions are expected to have a source range, the caller must
// provide one. Ideally this should be a real source range, but it can
// be a synthetic one (with an empty-string filename) if no suitable range
// is available.
func StaticExpr(val cty.Value, rng Range) Expression {
return staticExpr{val, rng}
}
func (e staticExpr) Value(ctx *EvalContext) (cty.Value, Diagnostics) {
return e.val, nil
}
func (e staticExpr) Variables() []Traversal {
return nil
}
func (e staticExpr) Range() Range {
return e.rng
}
func (e staticExpr) StartRange() Range {
return e.rng
}