naming

package
v0.77.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 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

Overview

Package naming validates and sanitizes ToolHive workload names.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidWorkloadName = httperr.WithCode(
	errors.New("invalid workload name"),
	http.StatusBadRequest,
)

ErrInvalidWorkloadName is returned when a workload name fails validation.

Functions

func SanitizeWorkloadName

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.

Types

type WorkloadNameIssue

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