secretref: secret://, env:, file:, base64: references (from yavebu) for yacry and yadenes

Adds IsReference for programs that keep accepting literals, and
YasevaConfig (passed as --config).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
terminarandClaude Opus 5.5 committed 2026-10-12 12:17:04 +02:00
1 parent 13c1862c74
commit 43775950a4
3 files changed
+408

No files matched your search

+24
View File
@@ -16,6 +16,7 @@ yetano.dev/yetano/core/config
yetano.dev/yetano/core/manual
yetano.dev/yetano/core/completion
yetano.dev/yetano/core/doctor
yetano.dev/yetano/core/secretref
```
Target platforms: Linux, FreeBSD, macOS, Windows. No Unix assumptions
@@ -302,3 +303,26 @@ docs/program-conventions.md in the meta-repository):
Tagged as plain semver on this repository (`v0.1.0`, ...), per the
meta-repo `AGENTS.md`'s versioning rules: an existing tag is never
force-moved to a different commit.
## core/secretref
Resolves secret references in a program's configuration, so a token or
password never has to be written into a config file in plain text:
| Form | Value from |
|---|---|
| `secret://<name>` | yaseva (`yaseva [--config <file>] get <name>`, run as a subprocess) |
| `env:<VARIABLE>` | the process environment |
| `file:<path>` | a file (`~` expanded, trailing newline trimmed) |
| `base64:<value>` | the value itself, base64 (standard or URL alphabet) -- out of plain sight, not protected |
```go
r := secretref.New("") // "yaseva" from PATH
token, err := r.ResolveString(ctx, cfg.Token)
log.Print(r.Redact(err.Error())) // resolved values become "***"
```
`Validate` accepts only these forms. A program that must keep reading
plain values it accepted before checks `IsReference` and treats anything
else as a literal. Used by yavebu (its own copy predates this package),
yacry and yadenes.