Documentation
¶
Overview ¶
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinaryOpSymbol ¶ added in v0.0.5
BinaryOpSymbol returns the HCL operator symbol for a binary operation (e.g. "+", "==").
func Dispatch ¶
func Dispatch[T any](expr hclsyntax.Expression, v Visitor[T]) (T, error)
Dispatch unwraps expr then dispatches to the appropriate Visitor method. Add new expression types here and to the Visitor interface so all sites stay in sync.
func UnaryOpSymbol ¶ added in v0.0.5
UnaryOpSymbol returns the HCL operator symbol for a unary operation (e.g. "-", "!").
func Unwrap ¶
func Unwrap(expr hclsyntax.Expression) hclsyntax.Expression
Unwrap returns the inner expression for wrapper types (TemplateWrapExpr, ParenthesesExpr, ObjectConsKeyExpr). For other expression types, returns expr unchanged. Callers can use this before their own type switch so wrapper handling is centralized.
Types ¶
type Visitor ¶
type Visitor[T any] interface { VisitLiteralValue(e *hclsyntax.LiteralValueExpr) (T, error) VisitTemplateExpr(e *hclsyntax.TemplateExpr) (T, error) VisitScopeTraversal(e *hclsyntax.ScopeTraversalExpr) (T, error) VisitIndexExpr(e *hclsyntax.IndexExpr) (T, error) VisitRelativeTraversal(e *hclsyntax.RelativeTraversalExpr) (T, error) VisitFunctionCall(e *hclsyntax.FunctionCallExpr) (T, error) VisitConditional(e *hclsyntax.ConditionalExpr) (T, error) VisitTupleCons(e *hclsyntax.TupleConsExpr) (T, error) VisitObjectCons(e *hclsyntax.ObjectConsExpr) (T, error) VisitTemplateJoin(e *hclsyntax.TemplateJoinExpr) (T, error) VisitBinaryOp(e *hclsyntax.BinaryOpExpr) (T, error) VisitUnaryOp(e *hclsyntax.UnaryOpExpr) (T, error) VisitForExpr(e *hclsyntax.ForExpr) (T, error) VisitSplatExpr(e *hclsyntax.SplatExpr) (T, error) VisitDefault(e hclsyntax.Expression) (T, error) }
Visitor is the interface for handling each HCL expression type in one place. Implement this interface for each dispatch site (engine, inspector, modules, converter). Adding a new expression type: add a method here and a case in Dispatch below.