utils

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: BSD-3-Clause Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(sel object.Selector[object.Refrence], field string) error

FormatSize converts bytes (int64) back to a human-readable size string. If the field doesn't exist or is nil, the function returns nil (no error). Returns an error if the field exists but is not an int64 or cannot be formatted.

func Global

Global wraps a transformer so it runs at the project scope and then at each instance of the nested container group (the per-app scope). container is the container group's config key, derived from the schema by the caller — an empty key means the schema has no container, so only the project scope is walked.

func IndexById

func IndexById(ct transform.Context[object.Refrence], group, name, id string) error

func ParseSize

func ParseSize(sel object.Selector[object.Refrence], field string) error

ParseSize parses a size string from the specified field and sets it as bytes (int64). If the field doesn't exist or is nil, the function returns nil (no error). Returns an error if the field exists but is not a string or cannot be parsed.

func RenameById

func RenameById(sel object.Selector[object.Refrence], name string) (string, error)

RenameById extracts the "id" field, sets "name" to the provided name, deletes the "id" field, and renames the selector to use the id value. Returns an error if the id field doesn't exist or is not a string.

func RenameByName

func RenameByName(sel object.Selector[object.Refrence]) (string, error)

RenameByName reverses RenameById - swaps ID/name back. Extracts the "name" field, sets "id" to the current key, deletes the "name" field, and renames the selector to use the name value. Returns the original name and an error if the name field doesn't exist or is not a string.

func ResolveNameToId

func ResolveNameToId(ct transform.Context[object.Refrence], group, name string) (string, error)

ResolveNameToId resolves a referenced name to its compiled id, honoring optional scope qualifiers on the name. The scoping is generic (every Ref benefits) and filesystem-like — a name is never a bare "/" or ".." (names are variable-names), so the qualifiers can't collide:

  • "name" current scope, then fall back to ancestors up to root (default)
  • "/name" the root/global scope only (absolute)
  • "../name" the parent scope, exact (repeatable: "../../name")

The default arm is byte-for-byte the previous behavior, so existing configs (and the parity oracle) are unaffected; the qualifiers are pure additions.

func ResolveNamesToId

func ResolveNamesToId(ct transform.Context[object.Refrence], group string, names []string) ([]string, error)

func ValidateMinMax

func ValidateMinMax(sel object.Selector[object.Refrence], minKey, maxKey string) error

ValidateMinMax checks that the value at maxKey is >= the value at minKey. If either key is missing or not an int, no error is returned (validation is skipped). Returns an error if both values are present and max < min.

Types

This section is empty.

Jump to

Keyboard shortcuts

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