Documentation
¶
Overview ¶
Package config provides configuration management for the application.
Index ¶
Constants ¶
const ( DefaultAPIURL = "https://api.scanoss.com" DefaultTimeout = 30 * time.Second DefaultMaxRetries = 3 DefaultRetryDelay = 5 * time.Second DefaultCacheTTL = 7 * 24 * time.Hour // 7 days for pinned versions DefaultLatestCacheTTL = 24 * time.Hour // 24 hours for @latest DefaultMaxStaleCacheAge = 30 * 24 * time.Hour // 30 days for stale cache fallback MaxStaleCacheAge = 90 * 24 * time.Hour // Maximum allowed: 90 days )
Default configuration values.
const ( // RootDirName is the root directory for SCANOSS configuration. RootDirName = ".scanoss" // AppDirName is the application-specific directory. AppDirName = "crypto-finder" // ConfigFileName is the configuration file name. ConfigFileName = "config.json" // CacheDirName is the cache directory name. CacheDirName = "cache" // RulesetsDirName is the rulesets cache directory name. RulesetsDirName = "rulesets" )
Variables ¶
This section is empty.
Functions ¶
func GetAppDir ¶
GetAppDir returns the path to the crypto-finder directory (~/.scanoss/crypto-finder) Creates the directory if it doesn't exist.
func GetCacheDir ¶
GetCacheDir returns the path to the cache directory (~/.scanoss/crypto-finder/cache) Creates the directory if it doesn't exist.
func GetConfigFilePath ¶
GetConfigFilePath returns the path to the config file (~/.scanoss/crypto-finder/config.json) Does not create the file if it doesn't exist.
func GetRootDir ¶
GetRootDir returns the path to the SCANOSS root directory (~/.scanoss) Creates the directory if it doesn't exist.
func GetRulesetsDir ¶
GetRulesetsDir returns the path to the rulesets cache directory (~/.scanoss/crypto-finder/cache/rulesets) Creates the directory if it doesn't exist.
func ResetInstance ¶
func ResetInstance()
ResetInstance resets the singleton instance. Only for testing purposes.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config manages application configuration.
func (*Config) Initialize ¶
Initialize loads configuration from multiple sources. Viper automatically handles priority (highest to lowest): 1. Set() calls (used for CLI flags) - highest 2. Environment variables (SCANOSS_API_KEY, SCANOSS_API_URL) 3. Config file (~/.scanoss/crypto-finder/config.json) 4. Defaults (SetDefault) - lowest
The order of setup below doesn't affect priority - viper handles it automatically.