hutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package hutil holds helpers shared by harness adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHeaderValues

func CheckHeaderValues(h map[string]string) error

CheckHeaderValues rejects header names or values containing CR or LF, which would let a value smuggle extra headers into newline-joined header lists.

func ClientModel added in v0.2.0

func ClientModel(c harness.Context, alias string) string

ClientModel is the model name a client should send for alias. Behind a gateway Halos runs (halo-proxy, kong) that is the alias itself; behind an external gateway nothing translates aliases, so it is the route's primary provider model id. An alias with no route is returned unchanged.

func DeepMerge

func DeepMerge(dst, src map[string]any) map[string]any

DeepMerge merges src into dst recursively (maps merge, everything else is replaced by src) and returns dst. src is never aliased into dst.

func JSON

func JSON(v any) ([]byte, error)

JSON renders v deterministically: sorted keys (maps), 2-space indent, trailing newline.

func Join

func Join(os harness.OS, parts ...string) string

Join joins path parts with the separator of the target OS.

func Model

func Model(p *policy.Profile, name string) string

Model is the default model alias for harness name: its own harnesses.<name>.model, else the profile's models.default.

func OTELResourceAttributes

func OTELResourceAttributes(name string, t policy.Telemetry, c harness.Context) string

OTELResourceAttributes is the OTEL_RESOURCE_ATTRIBUTES value for harness name: the profile's telemetry.attributes plus halo.harness, halo.ring, halo.release and, for a variant release, halo.experiment/halo.variant. halo.* are set last so a profile attribute cannot spoof them.

func OTELShellWrapper

func OTELShellWrapper(binary, attrs string) string

OTELShellWrapper is a /etc/profile.d function that runs binary with the release's OTEL_RESOURCE_ATTRIBUTES, for CLIs whose config has no resource-attribute key (they all honor the env var; test/uat). A function, not an export: every harness sets halo.harness, so one global variable would mislabel the others. Like other profile.d settings it reaches login shells (and, exported, their bash children); an exec that bypasses the shell (timeout, env, xargs) runs the CLI unlabeled.

func PctEncode

func PctEncode(s string) string

PctEncode percent-encodes s for OTEL resource attributes (RFC 3986 unreserved kept).

func Populated

func Populated(p *policy.Profile) []string

Populated lists the profile fields that are set, by dotted name.

func Protocol

func Protocol(g *policy.Gateway, harnessName, def string) string

Protocol returns the gateway protocol configured for harness, or def.

func ShQuote

func ShQuote(s string) string

ShQuote single-quotes s for POSIX sh.

func SortedKeys

func SortedKeys[V any](m map[string]V) []string

SortedKeys returns m's keys sorted.

func VersionBefore

func VersionBefore(v string, major, minor int) bool

VersionBefore reports whether a "major.minor[.patch...]" version is below major.minor. Unparseable versions report false (nothing to warn about).

func WarnUnsupported

func WarnUnsupported(adapter string, p *policy.Profile, handled ...string) []string

WarnUnsupported returns one warning per populated profile field not in handled.

Types

This section is empty.

Directories

Path Synopsis
Package hutiltest provides a shared rich fixture and golden-file helper for adapter tests.
Package hutiltest provides a shared rich fixture and golden-file helper for adapter tests.

Jump to

Keyboard shortcuts

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