util

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 10 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 (
	ServiceTypeTimescaleDB = "timescaledb"
	ServiceTypePostgres    = "postgres"
	ServiceTypeVector      = "vector"
)

Service type constants

Variables

This section is empty.

Functions

func AnySlice

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

func Deref

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

func DerefStr

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

func GenerateServiceName

func GenerateServiceName() string

Matches front-end logic for generating a random service name

func IsValidServiceType

func IsValidServiceType(serviceType string) bool

IsValidServiceType checks if the given service type is valid (case-insensitive)

func Must

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

func ParseCPUMemory

func ParseCPUMemory(cpuMemoryStr string) (int, float64, 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 ValidServiceTypes

func ValidServiceTypes() []string

ValidServiceTypes returns a slice of all valid service types

func ValidateAndNormalizeCPUMemory

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

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

Types

type CPUMemoryConfig

type CPUMemoryConfig struct {
	CPUMillis int     // CPU in millicores
	MemoryGbs float64 // 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

type KeyringStorage

type KeyringStorage struct{}

KeyringStorage implements password storage using system keyring

func (*KeyringStorage) Get

func (k *KeyringStorage) Get(service api.Service) (string, error)

func (*KeyringStorage) GetStorageResult

func (k *KeyringStorage) GetStorageResult(err error, password string) PasswordStorageResult

func (*KeyringStorage) Remove

func (k *KeyringStorage) Remove(service api.Service) error

func (*KeyringStorage) Save

func (k *KeyringStorage) Save(service api.Service, password string) error

type NoStorage

type NoStorage struct{}

NoStorage implements no password storage (passwords are not saved)

func (*NoStorage) Get

func (n *NoStorage) Get(service api.Service) (string, error)

func (*NoStorage) GetStorageResult

func (n *NoStorage) GetStorageResult(err error, password string) PasswordStorageResult

func (*NoStorage) Remove

func (n *NoStorage) Remove(service api.Service) error

func (*NoStorage) Save

func (n *NoStorage) Save(service api.Service, password string) error

type PasswordStorage

type PasswordStorage interface {
	Save(service api.Service, password string) error
	Get(service api.Service) (string, error)
	Remove(service api.Service) error
	GetStorageResult(err error, password string) PasswordStorageResult
}

PasswordStorage defines the interface for password storage implementations

func GetPasswordStorage

func GetPasswordStorage() PasswordStorage

GetPasswordStorage returns the appropriate PasswordStorage implementation based on configuration

type PasswordStorageResult

type PasswordStorageResult struct {
	Success bool   `json:"success"`
	Method  string `json:"method"`  // "keyring", "pgpass", or "none"
	Message string `json:"message"` // Human-readable message
}

PasswordStorageResult contains the result of password storage operations

func SavePasswordWithResult

func SavePasswordWithResult(service api.Service, password string) (PasswordStorageResult, error)

SavePasswordWithResult handles saving a password and returns both error and result info

type PgpassStorage

type PgpassStorage struct{}

PgpassStorage implements password storage using ~/.pgpass file

func (*PgpassStorage) Get

func (p *PgpassStorage) Get(service api.Service) (string, error)

func (*PgpassStorage) GetStorageResult

func (p *PgpassStorage) GetStorageResult(err error, password string) PasswordStorageResult

func (*PgpassStorage) Remove

func (p *PgpassStorage) Remove(service api.Service) error

func (*PgpassStorage) Save

func (p *PgpassStorage) Save(service api.Service, password string) error

Jump to

Keyboard shortcuts

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