types

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package types contains types and validation functions for workloads in ToolHive. This is separated to avoid circular dependencies with the core package.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidWorkloadName = fmt.Errorf("invalid workload name")

ErrInvalidWorkloadName is returned when a workload name fails validation.

Functions

func GetEffectiveProxyMode added in v0.3.8

func GetEffectiveProxyMode(transportType types.TransportType, proxyMode string) string

GetEffectiveProxyMode determines the effective proxy mode that clients should use For stdio transports, this returns the proxy mode (sse or streamable-http) For direct transports (sse/streamable-http), this returns the transport type as the proxy mode

func MatchesLabelFilters

func MatchesLabelFilters(workloadLabels, filters map[string]string) bool

MatchesLabelFilters checks if workload labels match all the specified filters

func ParseLabelFilters

func ParseLabelFilters(labelFilters []string) (map[string]string, error)

ParseLabelFilters parses label filters from a slice of strings and validates them.

func SanitizeWorkloadName added in v0.2.14

func SanitizeWorkloadName(name string) (string, bool)

SanitizeWorkloadName sanitizes a user-provided workload name to ensure it's safe for file paths. It applies the same security analysis as ValidateWorkloadName but transforms invalid characters instead of rejecting them. This provides a more permissive approach for user-facing scenarios where we want to accept user input and make it safe rather than rejecting it. Returns the sanitized name and a boolean indicating whether the name was modified.

func ValidateWorkloadName

func ValidateWorkloadName(name string) error

ValidateWorkloadName checks if the provided workload name is valid. This function performs strict validation and rejects invalid names.

func WorkloadFromContainerInfo

func WorkloadFromContainerInfo(container *runtime.ContainerInfo) (core.Workload, error)

WorkloadFromContainerInfo creates a Workload struct from the runtime container info.

Types

type WorkloadNameIssue added in v0.2.14

type WorkloadNameIssue struct {
	Type        string // "empty", "path_traversal", "absolute_path", "command_injection", "null_bytes", "invalid_chars", "too_long"
	Description string
	Position    int // For character-specific issues
}

WorkloadNameIssue represents a specific issue found in a workload name

Jump to

Keyboard shortcuts

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