Documentation
¶
Index ¶
- func BuildServerURL(normalizedURL string) string
- func Contains(s, substr string) bool
- func EnsureDir(dirPath string) error
- func EnsureDirWithMode(dirPath string, mode os.FileMode) error
- func FormatBinaryBytes(bytes uint64) string
- func FormatDateString(dateString string) (string, error)
- func FormatDateStringWithLocation(dateString string, loc *time.Location) (string, error)
- func FormatTime(t time.Time) string
- func FormatTimeWithLocation(t time.Time, loc *time.Location) string
- func GetARecord(host string) (net.IP, error)
- func GetExternalIP() (net.IP, error)
- func GetTimestampFromDeploymentID(deploymentID string) (time.Time, error)
- func IsLocalhost(serverURL string) bool
- func IsValidDomain(domain string) error
- func IsValidEmail(email string) bool
- func NormalizeServerURL(rawURL string) (string, error)
- func NormalizeVersion(version string) string
- func Ptr[T any](v T) *T
- func RestartCommand() string
- func RestartService() error
- func RestartServiceArgs() (string, []string)
- func SafeIDPrefix(id string) string
- func SanitizeString(input string) string
- func ValidatePort(port string) error
- type DebounceFunc
- type Debouncer
- type InitSystem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildServerURL ¶
BuildServerURL constructs the full URL for API calls
func EnsureDirWithMode ¶
EnsureDirWithMode creates the directory with custom permissions.
func FormatBinaryBytes ¶
func FormatDateString ¶
FormatDateString formats a date string in a simple, CLI-friendly format similar to Docker and Kubernetes tools (e.g., "2 minutes ago", "3 hours ago", "2 days ago")
func FormatDateStringWithLocation ¶
FormatDateStringWithLocation formats a date string for the specified timezone
func FormatTime ¶
FormatTime formats a time.Time in a simple, CLI-friendly format similar to Docker and Kubernetes tools (e.g., "2 minutes ago", "3 hours ago", "2 days ago")
func FormatTimeWithLocation ¶
FormatTimeWithLocation formats a time.Time for the specified timezone
func GetARecord ¶
GetARecord returns the first A record (IPv4 address) for the provided host. It returns an error if no A record is found.
func GetExternalIP ¶
GetExternalIP queries a public service for this machine's external IPv4. It returns the IP or an error.
func GetTimestampFromDeploymentID ¶
GetTimestampFromDeploymentID extracts time.Time from an ULID
func IsLocalhost ¶
IsLocalhost checks if the given server URL refers to the local machine. It handles various formats: with/without port, IPv4, IPv6.
func IsValidDomain ¶
func IsValidEmail ¶
func NormalizeServerURL ¶
NormalizeServerURL strips protocol and normalizes the server URL for storage
func NormalizeVersion ¶
NormalizeVersion strips the 'v' prefix from version strings for comparison
func Ptr ¶
func Ptr[T any](v T) *T
Ptr is a helper that returns a pointer to the given value. Useful for creating pointers to literals or values in a single expression.
func RestartCommand ¶
func RestartCommand() string
RestartCommand returns the command to restart haloyd for the detected init system
func RestartService ¶
func RestartService() error
RestartService executes the service restart command
func RestartServiceArgs ¶
RestartServiceArgs returns the command and arguments to restart haloyd
func SafeIDPrefix ¶
func SanitizeString ¶
SanitizeString takes a string and sanitizes it for use as a safe identifier. Allows alphanumeric characters, hyphens, and underscores. Consecutive disallowed characters are replaced by a single underscore.
func ValidatePort ¶
ValidatePort checks if a port string is a valid port number (1-65535)
Types ¶
type DebounceFunc ¶
type DebounceFunc func()
DebounceFunc defines the type for the function to be executed after debouncing.
type Debouncer ¶
type Debouncer struct {
// contains filtered or unexported fields
}
Debouncer manages debouncing calls for different keys.
func NewDebouncer ¶
NewDebouncer creates a new Debouncer.
func (*Debouncer) Debounce ¶
func (d *Debouncer) Debounce(key string, action DebounceFunc)
Debounce schedules or resets the timer for a given key. When the delay expires without subsequent calls for the same key, the action function is executed.
type InitSystem ¶
type InitSystem string
InitSystem represents the detected init system type
const ( InitSystemd InitSystem = "systemd" InitOpenRC InitSystem = "openrc" InitSysVInit InitSystem = "sysvinit" InitUnknown InitSystem = "unknown" )
func DetectInitSystem ¶
func DetectInitSystem() InitSystem
DetectInitSystem returns the init system used on the current machine