deferred

package
v0.4.3-final-apache Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JqQueryType = encapsulator.NewCodec("jq query", &encapsulator.CapsuleOps[JqQuery]{
	CustomExpressionDecoder: func(expr hcl.Expression, evalCtx *hcl.EvalContext) (val *JqQuery, diags diagnostics.Diag) {
		queryVal, diag := expr.Value(evalCtx)
		if diags.Extend(diag) {
			return
		}
		if queryVal.IsNull() || !queryVal.IsKnown() || !queryVal.Type().Equals(cty.String) {
			diags.Append(&hcl.Diagnostic{
				Severity:    hcl.DiagError,
				Summary:     "Invalid argument",
				Detail:      "A string is required",
				Subject:     expr.Range().Ptr(),
				Expression:  expr,
				EvalContext: evalCtx,
			})
			return
		}

		val = &JqQuery{
			query:    queryVal.AsString(),
			srcRange: expr.Range().Ptr(),
		}
		val.parseOnce = utils.OnceVal(val.parse)
		return
	},
})
View Source
var Type *encapsulator.Codec[deferredEval]

Type represents cty-type-erased deferred evaluation. This type is used to hide custom decoder on an inner type (i.e. JqQuery) to avoid repeated calls to custom decode.

Functions

func WithQueryFuncs

func WithQueryFuncs(ctx context.Context) context.Context

Adds "query_jq" function to the eval context

Types

type Evaluable

type Evaluable interface {
	DeferredEval(ctx context.Context, dataCtx plugindata.Map) (result cty.Value, diags diagnostics.Diag)
}

type JqQuery

type JqQuery struct {
	// contains filtered or unexported fields
}

func (*JqQuery) DeferredEval

func (q *JqQuery) DeferredEval(ctx context.Context, dataCtx plugindata.Map) (_ cty.Value, diags diagnostics.Diag)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL