config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config loads the user-global config (~/.config/notenv/config.toml, not committed) and merges it with the project contract into an effective configuration. Storage target is machine-only; the contract contributes just the namespace.

Index

Constants

View Source
const (
	DefaultBase         = "notenv"
	ModePass            = "passphrase"
	DefaultCacheTTL     = time.Hour // master-key keyring cache
	DefaultBlobCacheTTL = time.Hour // local ciphertext cache (matches key cache; --refresh forces fresh)
)

Variables

This section is empty.

Functions

func CacheScope

func CacheScope(remote, base string) string

CacheScope is the keyring cache key for a storage base. Length-prefixed on the remote so (remote, base) pairs can't alias: a plain "remote:base" join makes ("r","a:b") and ("r:a","b") collide.

func Dir

func Dir() (string, error)

Dir returns the user config directory, honoring XDG_CONFIG_HOME.

func Exists

func Exists() bool

Exists reports whether a user config file is present (the "is this machine set up" check).

func Path

func Path() (string, error)

func WriteUser

func WriteUser(remote, base string, versioned bool) (string, error)

WriteUser writes a fresh user config and returns its path.

Types

type Effective

type Effective struct {
	Remote       string // rclone remote name
	Base         string // path within the remote
	Versioned    bool   // remote retains versions on overwrite
	Namespace    string
	Mode         string        // crypto mode
	CacheTTL     time.Duration // master-key cache TTL; <= 0 disables caching
	BlobCacheTTL time.Duration // local ciphertext cache TTL; <= 0 disables
}

Effective is the merged result of user config + contract overrides.

func Resolve

func Resolve(u *User, f *contract.File, contractDir string) (Effective, error)

Resolve combines the machine config with the contract's namespace and applies defaults: base path "notenv", namespace = contract directory name, mode "passphrase".

type User

type User struct {
	Storage struct {
		Remote string `toml:"remote"`
		Base   string `toml:"base"`
		// Versioned: the remote retains old object versions on overwrite
		// (B2 does natively), so skip the ~3s server-side .prev backup copy.
		Versioned bool `toml:"versioned"`
		// CacheTTL bounds local ciphertext-cache lifetime (Go duration;
		// "0" disables). Default 1h. Same-machine writes refresh the cache
		// instantly; for another machine's change, `run --refresh` or wait
		// out the TTL.
		CacheTTL string `toml:"cache_ttl"`
	} `toml:"storage"`
	Crypto struct {
		Mode string `toml:"mode"`
		// CacheTTL is how long the passphrase cache may hold a passphrase
		// (Go duration string; "0" disables caching). Default: 1h.
		CacheTTL string `toml:"cache_ttl"`
	} `toml:"crypto"`
}

func LoadUser

func LoadUser() (*User, error)

LoadUser reads the user config. A missing file is not an error: it returns a zero-value config (callers surface the "no remote" error later).

Jump to

Keyboard shortcuts

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