Skip to main content

queryBuilderToExpr.go

queryBuilderToExpr.go - Overview

This file defines functions for parsing a v3.FilterSet into an expression string suitable for use with the expr package. It handles various filter operators and data types, converting them into a format that can be compiled and evaluated.

Detailed Documentation

logOperatorsToExpr

  • Purpose: A map that translates v3.FilterOperator values to their corresponding string representations in the expr language.
  • Parameters: None
  • Returns: None

getName

  • Purpose: Constructs the accessor string to reach the attribute value from the attributes or resources map.
  • Parameters:
    • v (v3.AttributeKey): The attribute key containing information about the attribute.
  • Returns:
    • string: A string representing how to access the attribute's value (e.g., attributes["key"], resource["key"], or just key).

getTypeName

  • Purpose: Returns the string representation of an AttributeKeyType.
  • Parameters:
    • v (v3.AttributeKeyType): The type of the attribute key (tag or resource).
  • Returns:
    • string: "attributes" if the type is v3.AttributeKeyTypeTag, "resource" if the type is v3.AttributeKeyTypeResource, and "" otherwise.

Parse

  • Purpose: Converts a v3.FilterSet into an expression string.
  • Parameters:
    • filters (*v3.FilterSet): The filter set to parse.
  • Returns:
    • string: The resulting expression string.
    • error: An error if the parsing fails.

exprFormattedValue

  • Purpose: Formats a value for use in an expression string.
  • Parameters:
    • v (interface{}): The value to format.
  • Returns:
    • string: The formatted value.

quoteEscapedString

  • Purpose: Escapes special characters in a string for use in an expression.
  • Parameters:
    • str (string): The string to escape.
  • Returns:
    • string: The escaped string.

Include in Getting Started: NO