config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxAge = 30 * 24 * time.Hour

DefaultMaxAge is the default maximum age for cache files (30 days).

Variables

This section is empty.

Functions

func DefaultProviders

func DefaultProviders() map[string]Provider

DefaultProviders returns builtin provider definitions.

func DirPath

func DirPath() (string, error)

DirPath returns ~/.config/cache-buster.

func EnsureDir

func EnsureDir() error

EnsureDir creates config directory if missing.

func ExpandPaths

func ExpandPaths(patterns []string) ([]string, error)

ExpandPaths expands ~ and globs in path patterns.

func ExpandTilde

func ExpandTilde(path string) (string, error)

ExpandTilde replaces ~ prefix with home directory.

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses duration strings like "30d", "24h", "60m", "3600s". Supports: d (days), h (hours), m (minutes), s (seconds). If empty string, returns DefaultMaxAge.

func Path

func Path() (string, error)

Path returns ~/.config/cache-buster/config.yaml.

func PathsExist added in v0.2.0

func PathsExist(patterns []string) bool

PathsExist checks if any of the given paths exist on disk.

Types

type Config

type Config struct {
	Providers map[string]Provider `mapstructure:"providers" yaml:"providers"`
	Version   string              `mapstructure:"version" yaml:"version"`
}

Config holds cache-buster configuration.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns config with all default providers.

func (*Config) AllEnabledProviders added in v0.2.0

func (c *Config) AllEnabledProviders() []string

AllEnabledProviders returns all enabled providers regardless of path existence.

func (*Config) EnabledProviders

func (c *Config) EnabledProviders() []string

EnabledProviders returns sorted list of enabled provider names with existing paths.

func (*Config) GetProvider

func (c *Config) GetProvider(name string) (Provider, bool)

GetProvider returns provider by name.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks config for required fields.

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader handles config file operations.

func NewLoader

func NewLoader() *Loader

NewLoader creates a new config loader.

func (*Loader) Exists

func (l *Loader) Exists() (bool, error)

Exists checks if config file exists.

func (*Loader) InitDefault

func (l *Loader) InitDefault() (bool, error)

InitDefault creates default config if missing. Returns true if created.

func (*Loader) Load

func (l *Loader) Load() (*Config, error)

Load reads config from disk and merges with defaults.

func (*Loader) LoadOrCreate deprecated

func (l *Loader) LoadOrCreate() (*Config, bool, error)

LoadOrCreate loads config (always merges with defaults). Returns (config, created, error).

Deprecated: Use Load() instead. The created return value is always false.

func (*Loader) Save

func (l *Loader) Save(cfg *Config) error

Save writes config to disk.

func (*Loader) SetConfigPath

func (l *Loader) SetConfigPath(path string)

SetConfigPath overrides config path (for testing).

func (*Loader) SkipDefaults added in v0.2.0

func (l *Loader) SkipDefaults()

SkipDefaults disables merging with defaults (for test isolation).

type Provider

type Provider struct {
	MaxSize  string   `mapstructure:"max_size" yaml:"max_size"`
	MaxAge   string   `mapstructure:"max_age" yaml:"max_age,omitempty"`
	CleanCmd string   `mapstructure:"clean_cmd" yaml:"clean_cmd,omitempty"`
	Paths    []string `mapstructure:"paths" yaml:"paths"`
	Enabled  bool     `mapstructure:"enabled" yaml:"enabled"`
}

Provider defines a cache provider's settings.

Jump to

Keyboard shortcuts

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