config

package
v1.0.36 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 4 Imported by: 0

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

View Source
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"
)
View Source
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.

View Source
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

func GetCacheTTL() time.Duration

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

func GetConfigDir() (string, error)

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

func GetConfigPath() (string, error)

GetConfigPath returns the full path to config.json

func GetCredentialsPath

func GetCredentialsPath() (string, error)

GetCredentialsPath returns the full path to credentials.json

func GetTokenPath

func GetTokenPath() (string, error)

GetTokenPath returns the full path to token.json (fallback storage)

func SaveConfig added in v1.0.30

func SaveConfig(cfg *Config) error

SaveConfig saves the user configuration to config.json

func ShortenPath

func ShortenPath(path string) string

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"`
	GrantedScopes []string `json:"granted_scopes,omitempty"`
}

Config represents user-configurable settings

func LoadConfig added in v1.0.30

func LoadConfig() (*Config, error)

LoadConfig loads the user configuration from config.json Returns default config if file doesn't exist

Jump to

Keyboard shortcuts

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