Documentation
¶
Overview ¶
Package hutil holds helpers shared by harness adapters.
Index ¶
- func CheckHeaderValues(h map[string]string) error
- func ClientModel(c harness.Context, alias string) string
- func DeepMerge(dst, src map[string]any) map[string]any
- func JSON(v any) ([]byte, error)
- func Join(os harness.OS, parts ...string) string
- func Model(p *policy.Profile, name string) string
- func OTELResourceAttributes(name string, t policy.Telemetry, c harness.Context) string
- func OTELShellWrapper(binary, attrs string) string
- func PctEncode(s string) string
- func Populated(p *policy.Profile) []string
- func Protocol(g *policy.Gateway, harnessName, def string) string
- func ShQuote(s string) string
- func SortedKeys[V any](m map[string]V) []string
- func VersionBefore(v string, major, minor int) bool
- func WarnUnsupported(adapter string, p *policy.Profile, handled ...string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckHeaderValues ¶
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
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 ¶
DeepMerge merges src into dst recursively (maps merge, everything else is replaced by src) and returns dst. src is never aliased into dst.
func Model ¶
Model is the default model alias for harness name: its own harnesses.<name>.model, else the profile's models.default.
func OTELResourceAttributes ¶
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 ¶
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 ¶
PctEncode percent-encodes s for OTEL resource attributes (RFC 3986 unreserved kept).
func SortedKeys ¶
SortedKeys returns m's keys sorted.
func VersionBefore ¶
VersionBefore reports whether a "major.minor[.patch...]" version is below major.minor. Unparseable versions report false (nothing to warn about).
Types ¶
This section is empty.