util

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 5 Imported by: 0 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

Index

Constants

View Source
const (
	AddonTimeSeries = "time-series"
	AddonAI         = "ai"
	AddonNone       = "none" // Special value for no add-ons
)

Addon constants - these match the ServiceCreateAddons from the API

Variables

This section is empty.

Functions

func AnySlice

func AnySlice[T any](in []T) []any

func ConvertStringSlice added in v0.4.1

func ConvertStringSlice[T ~string](ss []string) []T

ConvertStringSlice converts a slice of strings to another string-like type. Returns nil if the input slice is empty or nil.

func Deref

func Deref[T any](val *T) T

func DerefStr

func DerefStr[T ~string](val *T) string

func ExpandPath added in v0.4.0

func ExpandPath(path string) string

ExpandPath expands environment variables and tilde in file paths. It handles: - Empty paths (returns empty string) - Environment variable expansion (e.g., $HOME/config) - Home directory expansion (e.g., ~/config or ~) - Path normalization for cross-platform compatibility

func GenerateServiceName

func GenerateServiceName() string

Matches front-end logic for generating a random service name

func IsValidAddon added in v0.1.2

func IsValidAddon(addon string) bool

IsValidAddon checks if the given add-on is valid (case-sensitive as per API spec)

func Must

func Must[T any](v T, err error) T

func ParseCPUMemory

func ParseCPUMemory(cpuMemoryStr string) (int, int, error)

ParseCPUMemory parses a CPU/Memory combination string (e.g., "2 CPU/8GB") and returns millicores and GB

func Ptr

func Ptr[T any](val T) *T

func ValidAddons added in v0.1.2

func ValidAddons() []string

ValidAddons returns a slice of all valid add-on values

func ValidateAddons added in v0.1.2

func ValidateAddons(addons []string) ([]string, error)

ValidateAddons validates a slice of add-ons and removes duplicate values

func ValidateAndNormalizeCPUMemory

func ValidateAndNormalizeCPUMemory(cpuMillis int, memoryGbs int, cpuFlagSet, memoryFlagSet bool) (int, int, error)

ValidateAndNormalizeCPUMemory validates CPU/Memory values and applies auto-configuration logic

Types

type CPUMemoryConfig

type CPUMemoryConfig struct {
	CPUMillis int // CPU in millicores
	MemoryGbs int // Memory in GB
}

CPUMemoryConfig represents an allowed CPU/Memory configuration

func (*CPUMemoryConfig) CPUString

func (c *CPUMemoryConfig) CPUString() string

func (*CPUMemoryConfig) MemoryString

func (c *CPUMemoryConfig) MemoryString() string

func (*CPUMemoryConfig) String

func (c *CPUMemoryConfig) String() string

type CPUMemoryConfigs

type CPUMemoryConfigs []CPUMemoryConfig

func GetAllowedCPUMemoryConfigs

func GetAllowedCPUMemoryConfigs() CPUMemoryConfigs

GetAllowedCPUMemoryConfigs returns the allowed CPU/Memory configurations from the spec TODO: It would be great if we could fetch these from the API instead of hard coding them.

func (CPUMemoryConfigs) CPUString

func (c CPUMemoryConfigs) CPUString() string

String returns a user-friendly string of allowed CPU values

func (CPUMemoryConfigs) MemoryString

func (c CPUMemoryConfigs) MemoryString() string

String returns a user-friendly string of allowed memory values

func (CPUMemoryConfigs) String

func (c CPUMemoryConfigs) String() string

String returns a user-friendly string of allowed CPU/Memory combinations

func (CPUMemoryConfigs) Strings

func (c CPUMemoryConfigs) Strings() []string

Strings returns a slice of user-friendly strings of allowed CPU/Memory combinations

Jump to

Keyboard shortcuts

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