Documentation
¶
Index ¶
- Constants
- func AnySlice[T any](in []T) []any
- func ConvertStringSlicePtr[T ~string](ss []string) *[]T
- func Deref[T any](val *T) T
- func DerefStr[T ~string](val *T) string
- func ExpandPath(path string) string
- func GenerateServiceName() string
- func IsCI() bool
- func IsTerminal(w io.Writer) bool
- func IsValidAddon(addon string) bool
- func Must[T any](v T, err error) T
- func ParseCPUMemory(cpuMemoryStr string) (string, string, error)
- func Ptr[T any](val T) *T
- func SerializeToJSON(w io.Writer, v any) error
- func SerializeToYAML(w io.Writer, v any, omitNull bool) error
- func ValidAddons() []string
- func ValidateAddons(addons []string) ([]string, error)
- func ValidateAndNormalizeCPUMemory(cpuMillis, memoryGBs string) (*string, *string, error)
- type CPUMemoryConfig
- type CPUMemoryConfigs
Constants ¶
const ( AddonNone = "none" // Special value for no add-ons AddonTimeSeries = "time-series" AddonAI = "ai" )
Addon constants - these match the ServiceCreateAddons from the API
Variables ¶
This section is empty.
Functions ¶
func ConvertStringSlicePtr ¶ added in v0.9.0
ConvertStringSlicePtr converts a slice of strings to a pointer to another string-like type. Returns nil if the input slice is nil.
func ExpandPath ¶ added in v0.4.0
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 IsCI ¶ added in v0.10.0
func IsCI() bool
IsCI determines if the current execution context is within a known CI/CD system. This is based on https://github.com/watson/ci-info/blob/HEAD/index.js.
func IsTerminal ¶ added in v0.10.0
IsTerminal is a helper method for detecting whether an io.Writer is a interactive terminal / TTY.
func IsValidAddon ¶ added in v0.1.2
IsValidAddon checks if the given add-on is valid (case-sensitive as per API spec)
func ParseCPUMemory ¶
ParseCPUMemory parses a CPU/memory combination string (e.g., "2 CPU/8GB") and returns millicores and GB. If "shared" is given, returns "shared" for both CPU and memory.
func SerializeToYAML ¶ added in v0.10.0
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
ValidateAddons validates a slice of add-ons and removes duplicate values
Types ¶
type CPUMemoryConfig ¶
CPUMemoryConfig represents an allowed CPU/Memory configuration
func (*CPUMemoryConfig) Matches ¶ added in v0.9.0
func (c *CPUMemoryConfig) Matches(cpuMillis, memoryGBs string) (string, string, bool)
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
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