paths

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppName is the application name used in config paths
	AppName = "rivet"

	// ConfigFileName is the name of the config file
	ConfigFileName = "config.yaml"

	// StateFileName is the name of the state file
	StateFileName = "state.yaml"

	// LegacyConfigFileName is the old config file name
	LegacyConfigFileName = ".rivet.yaml"

	// LegacyStateFileName is the old state file name
	LegacyStateFileName = ".rivet.state.yaml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigSource

type ConfigSource int

ConfigSource indicates where a config file came from

const (
	SourceUnknown ConfigSource = iota
	SourceUserConfig
	SourceProjectConfig
	SourceRepoDefault
	SourceEnvVar
	SourceCLIFlag
)

func (ConfigSource) String

func (s ConfigSource) String() string

type Paths

type Paths struct {
	// UserConfigDir is the user's config directory (~/.config/rivet)
	UserConfigDir string

	// UserStateDir is the user's state directory (~/.local/state/rivet)
	UserStateDir string

	// UserCacheDir is the user's cache directory (~/.cache/rivet)
	UserCacheDir string

	// ProjectRoot is the root of the current git repository (if any)
	ProjectRoot string

	// RepoDefaultConfigPath is the path to the repository's default config (.github/.rivet.yaml)
	RepoDefaultConfigPath string

	// ProjectUserConfigPath is the path to the user's project-specific config (.git/.rivet/config.yaml)
	ProjectUserConfigPath string
	// contains filtered or unexported fields
}

Paths provides access to all application paths following XDG Base Directory specification

func New

func New() (*Paths, error)

New creates a new Paths instance with XDG-compliant directories

func NewWithProject

func NewWithProject(projectRoot string) (*Paths, error)

NewWithProject creates a new Paths instance with project-specific paths

func (*Paths) EnsureDirs

func (p *Paths) EnsureDirs() error

EnsureDirs creates all necessary directories if they don't exist. Following XDG Base Directory specification, it: - Attempts to create directories with permission 0700 (as per XDG spec) - Falls back to alternative directories if permission denied - Prints warnings for non-critical directory failures - Only fails if critical directories cannot be created

func (*Paths) FindLegacyConfig

func (p *Paths) FindLegacyConfig() (string, bool)

FindLegacyConfig searches for legacy config files in order of precedence Returns the path and whether it exists

func (*Paths) FindLegacyState

func (p *Paths) FindLegacyState() (string, bool)

FindLegacyState searches for legacy state files

func (*Paths) GetConfigPaths

func (p *Paths) GetConfigPaths() []string

GetConfigPaths returns all config paths in order of precedence (lowest to highest) The last path in the list has the highest priority

func (*Paths) GetConfigSource

func (p *Paths) GetConfigSource(path string) ConfigSource

GetConfigSource determines which source a config path corresponds to

func (*Paths) UserConfigFile

func (p *Paths) UserConfigFile() string

UserConfigFile returns the path to the user's main config file

func (*Paths) UserStateFile

func (p *Paths) UserStateFile(repoOwner, repoName string) string

UserStateFile returns the path to the user's state file for a specific repository

Jump to

Keyboard shortcuts

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