Documentation
¶
Overview ¶
Package quota provides storage quota management for hold services.
Index ¶
- func FormatHumanBytes(bytes int64) string
- func ParseHumanBytes(s string) (int64, error)
- type Config
- type DefaultsConfig
- type Manager
- func (m *Manager) GetDefaultTier() string
- func (m *Manager) GetTierLimit(tierKey string) *int64
- func (m *Manager) GetTierName(tierKey string) string
- func (m *Manager) IsEnabled() bool
- func (m *Manager) ListTiers() []TierInfo
- func (m *Manager) ScanOnPush(tierKey string) bool
- func (m *Manager) TierCount() int
- type TierConfig
- type TierInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatHumanBytes ¶
FormatHumanBytes formats bytes as a human-readable string
func ParseHumanBytes ¶
ParseHumanBytes parses human-readable byte sizes like "5GB", "100MB", "1.5TB"
Types ¶
type Config ¶
type Config struct {
// Quota tiers ordered by rank (lowest to highest). Position determines rank.
Tiers []TierConfig `yaml:"tiers" comment:"Quota tiers ordered by rank (lowest to highest). Position determines rank."`
// Default tier settings.
Defaults DefaultsConfig `yaml:"defaults" comment:"Default tier assignment for new crew members."`
}
Config represents quota tier configuration.
func (*Config) TierByName ¶
func (c *Config) TierByName(name string) *TierConfig
TierByName returns the TierConfig for the given name, or nil if not found.
type DefaultsConfig ¶
type DefaultsConfig struct {
// Name of the tier assigned to new crew members.
NewCrewTier string `yaml:"new_crew_tier" comment:"Tier assigned to new crew members who don't have an explicit tier."`
}
DefaultsConfig represents default settings.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages quota configuration and tier resolution
func NewManager ¶
NewManager creates a quota manager, loading config from file if present
func NewManagerFromConfig ¶
NewManagerFromConfig creates a quota manager from an in-memory Config struct. If cfg is nil or has no tiers, quotas are disabled (same as missing file).
func (*Manager) GetDefaultTier ¶
GetDefaultTier returns the default tier name for new crew members
func (*Manager) GetTierLimit ¶
GetTierLimit resolves the quota limit for a tier key Returns nil for unlimited (captain, no config, or tier not found with no default)
Resolution order: 1. If quotas disabled → nil (unlimited) 2. If tierKey provided and found → return that tier's limit 3. If tierKey not found or empty → use defaults.new_crew_tier 4. If default tier not found → nil (unlimited)
func (*Manager) GetTierName ¶
GetTierName resolves the tier name for a tier key Returns the actual tier name being used (after fallback resolution)
func (*Manager) ListTiers ¶
ListTiers returns all configured tiers with their limits, in rank order (lowest to highest).
func (*Manager) ScanOnPush ¶
ScanOnPush returns whether scan-on-push is enabled for a tier. Follows the same fallback logic as GetTierLimit:
- If quotas disabled → false (caller decides default)
- If tierKey provided and found → that tier's ScanOnPush
- If tierKey not found or empty → use defaults.new_crew_tier
- If default tier not found → false
type TierConfig ¶
type TierConfig struct {
// Tier name (e.g. "deckhand", "bosun", "quartermaster").
Name string `yaml:"name" comment:"Tier name used as the key for crew assignments."`
// Human-readable size limit, e.g. "5GB", "50GB", "1TB".
Quota string `yaml:"quota" comment:"Storage quota limit (e.g. \"5GB\", \"50GB\", \"1TB\")."`
// Whether pushing triggers an immediate vulnerability scan.
ScanOnPush bool `` /* 140-byte string literal not displayed */
}
TierConfig represents a single tier's configuration.