stdlib

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package stdlib implements the Terramate language functions.

Index

Constants

View Source
const (
	TreeErrorInvalidInput       errors.Kind = "tree: invalid input"
	TreeErrorConflictingParents errors.Kind = "tree: conflicting parents"
	TreeErrorUnknownParent      errors.Kind = "tree: unknown parent"
	TreeErrorCycle              errors.Kind = "tree: cycle detected"
	TreeErrorNullChild          errors.Kind = "tree: null child"
	TreeErrorEmptyString        errors.Kind = "tree: empty string"
)

TreeError kinds for tm_tree function errors

View Source
const (
	// ErrUnslugIndeterministic indicates that a slug maps to multiple dictionary entries
	ErrUnslugIndeterministic errors.Kind = "tm_unslug indeterministic mapping"

	// ErrUnslugInvalidDictionaryType indicates the dictionary contains non-string elements
	ErrUnslugInvalidDictionaryType errors.Kind = "tm_unslug invalid dictionary type"

	// ErrUnslugInvalidValueType indicates the value is not a string or list of strings
	ErrUnslugInvalidValueType errors.Kind = "tm_unslug invalid value type"

	// ErrUnslugInternal indicates an unexpected internal failure
	ErrUnslugInternal errors.Kind = "tm_unslug internal error"
)

Error kinds for tm_unslug function

View Source
const ErrTomlDecode errors.Kind = "failed to decode toml content"

ErrTomlDecode represents errors happening during decoding of TOML content.

View Source
const JoinListInvalidArgumentType errors.Kind = "tm_joinlist: invalid argument type"

JoinListInvalidArgumentType is returned when the second argument to tm_joinlist is not a list or tuple.

View Source
const JoinListInvalidElementType errors.Kind = "tm_joinlist: invalid element type"

JoinListInvalidElementType is returned when an element in the list is not a list or tuple of strings.

View Source
const JoinListInvalidListElementType errors.Kind = "tm_joinlist: invalid list element type"

JoinListInvalidListElementType is returned when a list element contains non-string values.

View Source
const JoinListInvalidTupleElementType errors.Kind = "tm_joinlist: invalid tuple element type"

JoinListInvalidTupleElementType is returned when a tuple element contains non-string values.

View Source
const SlugListElementNotString errors.Kind = "tm_slug: list element not string"

SlugListElementNotString is returned when a list element is not a string.

View Source
const SlugWrongType errors.Kind = "tm_slug: wrong type"

SlugWrongType is returned when tm_slug receives an invalid type.

View Source
const TomlExperimentName = "toml-functions"

TomlExperimentName is the name for the TOML experiment.

Variables

This section is empty.

Functions

func AbspathFunc

func AbspathFunc(basedir string) function.Function

AbspathFunc returns the `tm_abspath()` hcl function.

func Functions

func Functions(basedir string, experiments []string) map[string]function.Function

Functions returns all the Terramate default functions. The `basedir` must be an absolute path for an existent directory or it panics.

func HCLDecode added in v0.10.4

func HCLDecode() function.Function

HCLDecode implements the `tm_hcldecode` function.

func HCLEncode added in v0.10.4

func HCLEncode() function.Function

HCLEncode implements the `tm_hclencode()` function.

func HCLExpressionFunc

func HCLExpressionFunc() function.Function

HCLExpressionFunc returns the tm_hcl_expression function. This function interprets the `expr` argument as a string and returns the parsed expression.

func JoinListFunc added in v0.14.5

func JoinListFunc() function.Function

JoinListFunc implements the `tm_joinlist()` function. tm_joinlist(separator: string, list_of_lists: list(list(string))) -> list(string) It joins each sublist in the list_of_lists using the separator.

func JoinListInvalidArgumentTypeError added in v0.14.5

func JoinListInvalidArgumentTypeError(got string) error

JoinListInvalidArgumentTypeError creates an error for invalid argument type.

func JoinListInvalidElementTypeError added in v0.14.5

func JoinListInvalidElementTypeError(index int64, got string) error

JoinListInvalidElementTypeError creates an error for invalid element type.

func JoinListInvalidListElementTypeError added in v0.14.5

func JoinListInvalidListElementTypeError(index int64, got string) error

JoinListInvalidListElementTypeError creates an error for invalid list element type.

func JoinListInvalidTupleElementTypeError added in v0.14.5

func JoinListInvalidTupleElementTypeError(listIndex int64, elementIndex int, got string) error

JoinListInvalidTupleElementTypeError creates an error for invalid tuple element type.

func Name

func Name(name string) string

Name converts the function name into the exported Terramate name.

func NewUnslugErrorIndeterministic added in v0.14.5

func NewUnslugErrorIndeterministic(slug string, candidates []string) error

NewUnslugErrorIndeterministic creates an error for when a slug maps to multiple dictionary entries

func NoFS added in v0.4.1

func NoFS(basedir string, experiments []string) map[string]function.Function

NoFS returns all Terramate functions but excluding fs-related functions.

func Regex

func Regex() function.Function

Regex is a copy of Terraform stdlib.RegexFunc but with cached compiled patterns.

func SlugFunc added in v0.14.5

func SlugFunc() function.Function

SlugFunc returns the `tm_slug` function spec. It accepts either a string or list(string) and returns the appropriately typed slugified result.

func TernaryFunc

func TernaryFunc() function.Function

TernaryFunc is the `tm_ternary` function implementation. The `tm_ternary(cond, expr1, expr2)` will return expr1 if `cond` evaluates to `true` and `expr2` otherwise.

func TomlDecode added in v0.10.3

func TomlDecode() function.Function

TomlDecode implements the `tm_tomldecode` function.

func TomlEncode added in v0.10.3

func TomlEncode() function.Function

TomlEncode implements the `tm_tomlencode()` function.

func TreeErrorConflictingParentsValue added in v0.14.5

func TreeErrorConflictingParentsValue(child, parent1, parent2 string) error

TreeErrorConflictingParentsValue creates an error for conflicting parents

func TreeErrorCycleDetected added in v0.14.5

func TreeErrorCycleDetected(path []string) error

TreeErrorCycleDetected creates an error for cycle detection

func TreeErrorCycleNode added in v0.14.5

func TreeErrorCycleNode(node string) error

TreeErrorCycleNode creates a simple cycle error with just the node name

func TreeErrorEmptyChild added in v0.14.5

func TreeErrorEmptyChild() error

TreeErrorEmptyChild creates an error for empty child string

func TreeErrorEmptyParent added in v0.14.5

func TreeErrorEmptyParent() error

TreeErrorEmptyParent creates an error for empty parent string

func TreeErrorInvalidPairLength added in v0.14.5

func TreeErrorInvalidPairLength() error

TreeErrorInvalidPairLength creates an error for invalid pair length

func TreeErrorNullChildValue added in v0.14.5

func TreeErrorNullChildValue() error

TreeErrorNullChildValue creates an error for null child value

func TreeErrorUnknownParentValue added in v0.14.5

func TreeErrorUnknownParentValue(parent, child string) error

TreeErrorUnknownParentValue creates an error for unknown parent

func TreeFunc added in v0.14.5

func TreeFunc() function.Function

TreeFunc returns the `tm_tree` function spec. This function builds a tree/forest from a list of [parent, child] pairs and returns all branch paths from root to each node.

func TryFunc added in v0.4.4

func TryFunc() function.Function

TryFunc implements the `tm_try()` function.

func UnslugFunc added in v0.14.5

func UnslugFunc() function.Function

UnslugFunc returns the tm_unslug function.

func VendorFunc

func VendorFunc(basedir, vendordir project.Path, stream chan<- event.VendorRequest) function.Function

VendorFunc returns the `tm_vendor` function. The basedir defines what tm_vendor will use to define the relative paths of vendored dependencies. The vendordir defines where modules are vendored inside the project. The stream defines the event stream for tm_vendor, one event is produced per successful function call.

func VersionMatch

func VersionMatch() function.Function

VersionMatch returns the `tm_version_match` function spec, which checks if the provided version matches the constraint. If the third argument is provided, then it uses the flags to customize the version matcher. At the moment, only the propery `allow_prereleases` is supported, which enables matchs against prereleases using default Semver ordering semantics.

Types

This section is empty.

Jump to

Keyboard shortcuts

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