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 ¶
- Variables
- func GetEffectiveProxyMode(transportType types.TransportType, proxyMode string) string
- func MatchesLabelFilters(workloadLabels, filters map[string]string) bool
- func ParseLabelFilters(labelFilters []string) (map[string]string, error)
- func SanitizeWorkloadName(name string) (string, bool)
- func ValidateWorkloadName(name string) error
- func WorkloadFromContainerInfo(container *runtime.ContainerInfo, runConfigStore state.Store) (core.Workload, error)
- type WorkloadNameIssue
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidWorkloadName = httperr.WithCode( errors.New("invalid workload name"), http.StatusBadRequest, )
ErrInvalidWorkloadName is returned when a workload name fails validation.
Functions ¶
func GetEffectiveProxyMode ¶ added in v0.3.7
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 ¶
MatchesLabelFilters checks if workload labels match all the specified filters
func ParseLabelFilters ¶
ParseLabelFilters parses label filters from a slice of strings and validates them.
func SanitizeWorkloadName ¶ added in v0.2.14
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 ¶
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, runConfigStore state.Store) (core.Workload, error)
WorkloadFromContainerInfo creates a Workload struct from the runtime container info. The runConfigStore is used to load run configuration fields (proxy mode, group) without hitting the real filesystem, enabling proper dependency injection for tests.
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