config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config handles configuration loading, saving, and credential management.

Index

Constants

View Source
const (
	// KeyringService is the service name used for keyring storage.
	KeyringService = "repog"
	// KeyringGitHubPAT is the keyring key for the GitHub PAT.
	KeyringGitHubPAT = "github_pat"
	// KeyringGeminiAPIKey is the keyring key for the Gemini API key.
	KeyringGeminiAPIKey = "gemini_api_key"
	// ConfigVersion is the current config file version.
	ConfigVersion = 2
)

Variables

View Source
var ErrNotConfigured = errors.New("repog is not configured — run `repog init` first")

ErrNotConfigured is returned when repog has not been initialised.

Functions

func ClearConfig

func ClearConfig() error

ClearConfig removes the config file and deletes keyring entries.

func DefaultDBPath

func DefaultDBPath() string

DefaultDBPath returns the default database path.

func GetGeminiAPIKey

func GetGeminiAPIKey() (string, error)

GetGeminiAPIKey retrieves the Gemini API key from the keyring.

func GetGitHubPAT

func GetGitHubPAT() (string, error)

GetGitHubPAT retrieves the GitHub PAT from the keyring.

func IsConfigured

func IsConfigured() bool

IsConfigured returns true if config file exists and both secrets are present in the keyring.

func SaveConfig

func SaveConfig(cfg *Config, githubPAT, geminiAPIKey string) error

SaveConfig writes config to disk and stores secrets in the keyring.

func SetKeyringBackend

func SetKeyringBackend(kb KeyringBackend)

SetKeyringBackend sets the keyring backend (for testing).

Types

type Config

type Config struct {
	DBPath        string `yaml:"db_path"`
	ConfigVersion int    `yaml:"config_version"`
}

Config represents the on-disk configuration.

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig reads config from disk. Returns ErrNotConfigured if config file does not exist or either secret is missing from the keyring.

type KeyringBackend

type KeyringBackend interface {
	Set(service, key, value string) error
	Get(service, key string) (string, error)
	Delete(service, key string) error
}

KeyringBackend defines the interface for keyring operations. This allows mocking in tests.

Jump to

Keyboard shortcuts

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