utils

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerName

func ContainerName(project, environment, service string, replica int) string

ContainerName generates a standardized container name

func Errorf

func Errorf(format string, args ...interface{}) error

Errorf creates a formatted error

func ImageTag

func ImageTag(project, service, version, environment string) string

ImageTag generates a standardized image tag

func IsValidUnixUsername added in v0.2.4

func IsValidUnixUsername(name string) bool

IsValidUnixUsername validates that a string is a safe POSIX username. Rules: starts with letter or underscore, contains only letters, digits, underscores, and hyphens, max 32 characters.

func JoinNonEmpty

func JoinNonEmpty(sep string, parts ...string) string

JoinNonEmpty joins non-empty strings with a separator

func NetworkName

func NetworkName(project, environment string) string

NetworkName generates a standardized network name

func Quote

func Quote(s string) string

Quote wraps a string in single quotes if it contains spaces

func SanitizeDomainForLabel

func SanitizeDomainForLabel(domain string) string

SanitizeDomainForLabel converts a domain to a safe label name Example: "app.example.com" → "app-example-com"

func SanitizeName

func SanitizeName(name string) string

SanitizeName sanitizes a string for use in Docker/network names Replaces invalid characters with underscores

func ShellQuote added in v0.2.4

func ShellQuote(s string) string

ShellQuote wraps a string in single quotes with proper escaping for safe use in shell commands. Single quotes within the string are handled by ending the quoted section, adding an escaped single quote, and resuming quoting.

func TruncateString

func TruncateString(s string, maxLength int) string

TruncateString truncates a string to maxLength, adding "..." if truncated

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Wrapf wraps an error with a formatted message

Types

type Error

type Error struct {
	Operation string   // What operation was being performed
	Cause     error    // The underlying error
	Details   []string // Additional context
}

Error represents a Tako CLI error with context

func NewError

func NewError(operation string, cause error, details ...string) *Error

NewError creates a new Tako CLI error

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying error

type MultiError

type MultiError struct {
	Errors []error
}

Multi error type for collecting multiple errors

func (*MultiError) Add

func (m *MultiError) Add(err error)

Add adds an error to the collection

func (*MultiError) Error

func (m *MultiError) Error() string

Error implements the error interface

func (*MultiError) ErrorOrNil

func (m *MultiError) ErrorOrNil() error

ErrorOrNil returns the error if there are any, otherwise nil

func (*MultiError) HasErrors

func (m *MultiError) HasErrors() bool

HasErrors returns true if there are any errors

Jump to

Keyboard shortcuts

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