utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 2 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 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 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 DockerLabelBuilder

type DockerLabelBuilder struct {
	// contains filtered or unexported fields
}

DockerLabelBuilder helps build Docker labels in a type-safe way

func NewDockerLabelBuilder

func NewDockerLabelBuilder() *DockerLabelBuilder

NewDockerLabelBuilder creates a new label builder

func (*DockerLabelBuilder) Add

func (b *DockerLabelBuilder) Add(key, value string) *DockerLabelBuilder

Add adds a label with key and value

func (*DockerLabelBuilder) AddIf

func (b *DockerLabelBuilder) AddIf(condition bool, key, value string) *DockerLabelBuilder

AddIf conditionally adds a label if condition is true

func (*DockerLabelBuilder) AddRaw

func (b *DockerLabelBuilder) AddRaw(label string) *DockerLabelBuilder

AddRaw adds a raw label string (use with caution)

func (*DockerLabelBuilder) AddWithQuotes

func (b *DockerLabelBuilder) AddWithQuotes(key, value, quoteType string) *DockerLabelBuilder

AddWithQuotes adds a label with the value wrapped in the specified quote type quoteType can be "single" or "double"

func (*DockerLabelBuilder) Build

func (b *DockerLabelBuilder) Build() string

Build returns the labels as a space-separated string

func (*DockerLabelBuilder) BuildSlice

func (b *DockerLabelBuilder) BuildSlice() []string

BuildSlice returns the labels as a slice

func (*DockerLabelBuilder) Count

func (b *DockerLabelBuilder) Count() int

Count returns the number of labels

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

type RedirectDomainBuilder added in v0.0.3

type RedirectDomainBuilder struct {
	// contains filtered or unexported fields
}

RedirectDomainBuilder helps build redirect configurations for domain redirects

func NewRedirectDomainBuilder added in v0.0.3

func NewRedirectDomainBuilder(containerName, primaryDomain string) *RedirectDomainBuilder

NewRedirectDomainBuilder creates a new redirect domain builder

func (*RedirectDomainBuilder) AddRedirectDomain added in v0.0.3

func (r *RedirectDomainBuilder) AddRedirectDomain(redirectDomain string, index int, certResolver string) *RedirectDomainBuilder

AddRedirectDomain adds a domain that should redirect to the primary domain

func (*RedirectDomainBuilder) Build added in v0.0.3

func (r *RedirectDomainBuilder) Build() string

Build returns all redirect labels as a space-separated string

func (*RedirectDomainBuilder) BuildSlice added in v0.0.3

func (r *RedirectDomainBuilder) BuildSlice() []string

BuildSlice returns all redirect labels as a slice

type TraefikLabelBuilder

type TraefikLabelBuilder struct {
	*DockerLabelBuilder
	// contains filtered or unexported fields
}

TraefikLabelBuilder specifically for Traefik labels

func NewTraefikLabelBuilder

func NewTraefikLabelBuilder(routerName, serviceName string) *TraefikLabelBuilder

NewTraefikLabelBuilder creates a builder for Traefik labels

func (*TraefikLabelBuilder) Enable

Enable enables Traefik for this container

func (*TraefikLabelBuilder) Entrypoints

func (t *TraefikLabelBuilder) Entrypoints(entrypoints ...string) *TraefikLabelBuilder

Entrypoints sets the entrypoints for the router

func (*TraefikLabelBuilder) HealthCheck

func (t *TraefikLabelBuilder) HealthCheck(path string, interval string) *TraefikLabelBuilder

HealthCheck adds health check configuration

func (*TraefikLabelBuilder) HostRule

func (t *TraefikLabelBuilder) HostRule(domain string) *TraefikLabelBuilder

HostRule adds a Host() rule for the router

func (*TraefikLabelBuilder) Middlewares added in v0.0.3

func (t *TraefikLabelBuilder) Middlewares(middlewares ...string) *TraefikLabelBuilder

Middlewares adds middleware(s) to the router

func (*TraefikLabelBuilder) Port

Port sets the service port

func (*TraefikLabelBuilder) Priority

func (t *TraefikLabelBuilder) Priority(priority int) *TraefikLabelBuilder

Priority sets the router priority

func (*TraefikLabelBuilder) RedirectRegexMiddleware added in v0.0.3

func (t *TraefikLabelBuilder) RedirectRegexMiddleware(middlewareName, fromDomain, toDomain string, permanent bool) *TraefikLabelBuilder

RedirectRegexMiddleware creates a redirect regex middleware This is used to redirect one domain to another (e.g., www -> non-www)

func (*TraefikLabelBuilder) Service

func (t *TraefikLabelBuilder) Service(serviceName string) *TraefikLabelBuilder

Service links the router to a specific service

func (*TraefikLabelBuilder) TLS

func (t *TraefikLabelBuilder) TLS(certResolver string) *TraefikLabelBuilder

TLS enables TLS for the router

Jump to

Keyboard shortcuts

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