Documentation
¶
Overview ¶
Package config provides centralized configuration management for the application. It has no external dependencies to avoid circular imports with other internal packages.
Index ¶
- Constants
- func GetCacheTTL() time.Duration
- func GetCacheTTLHours() int
- func GetConfigDir() (string, error)
- func GetConfigPath() (string, error)
- func GetCredentialsPath() (string, error)
- func GetTokenPath() (string, error)
- func SaveConfig(cfg *Config) error
- func ShortenPath(path string) string
- type Config
Constants ¶
const ( // DirName is the name of the configuration directory DirName = "google-readonly" // CredentialsFile is the name of the OAuth credentials file CredentialsFile = "credentials.json" // TokenFile is the name of the OAuth token file (fallback storage) TokenFile = "token.json" )
const ( // DirPerm is the permission for config directories (owner read/write/execute only) DirPerm = 0700 // TokenPerm is the permission for token files (owner read/write only) TokenPerm = 0600 // OutputDirPerm is the permission for output directories (owner all, group/other read/execute) OutputDirPerm = 0755 // OutputFilePerm is the permission for output files (owner read/write, group/other read) OutputFilePerm = 0644 )
File and directory permission constants for consistent security settings.
const ( // ConfigFile is the name of the user configuration file ConfigFile = "config.json" // DefaultCacheTTLHours is the default cache TTL in hours DefaultCacheTTLHours = 24 )
Variables ¶
This section is empty.
Functions ¶
func GetCacheTTL ¶ added in v1.0.30
GetCacheTTL returns the configured cache TTL duration
func GetCacheTTLHours ¶ added in v1.0.30
func GetCacheTTLHours() int
GetCacheTTLHours returns the configured cache TTL in hours
func GetConfigDir ¶
GetConfigDir returns the configuration directory path, creating it if needed. Uses XDG_CONFIG_HOME if set, otherwise ~/.config/google-readonly
func GetConfigPath ¶ added in v1.0.30
GetConfigPath returns the full path to config.json
func GetCredentialsPath ¶
GetCredentialsPath returns the full path to credentials.json
func GetTokenPath ¶
GetTokenPath returns the full path to token.json (fallback storage)
func SaveConfig ¶ added in v1.0.30
SaveConfig saves the user configuration to config.json
func ShortenPath ¶
ShortenPath replaces the home directory prefix with ~ for display purposes. This prevents exposing full paths including usernames in error messages.
Types ¶
type Config ¶ added in v1.0.30
type Config struct {
CacheTTLHours int `json:"cache_ttl_hours"`
}
Config represents user-configurable settings
func LoadConfig ¶ added in v1.0.30
LoadConfig loads the user configuration from config.json Returns default config if file doesn't exist