Documentation
¶
Overview ¶
Package credential is the one reader every adapter resolves an external credential through, by NAME.
This is the interim source itd-2609061543533170 ruled for `abcd site setup` (its `## Decisions`, 2026-09-25): the credential store proper, with its three homes and its walkthrough, is itd-2609221017023290, which is planned and not built. Until it lands, a credential is read from one machine-scoped file, ~/.abcd/credentials.json, a JSON object mapping a credential name to its value. The successor replaces the source behind Source; no reader changes.
The file is refused, loudly and never treated as absent, unless it is a regular file (not a symlink), owned by the caller, and readable and writable by the owner alone (mode 0600 or tighter): a secret that group or other can read is not kept, and one that somebody else wrote is not the caller's.
The value never leaves Resolve except as its return: no error formats it, nothing logs it, and nothing here writes to the repository. The one write is SetMachine, into this same file, for the setup of the OpenAI-compatible API adapter (itd-2609081951381895). A malformed file is refused without echoing a byte of it.
Index ¶
Constants ¶
const MaxValueBytes = 4096
MaxValueBytes bounds one credential's value.
const StoreFileName = "credentials.json"
StoreFileName is the interim store's file under ~/.abcd/.
const StorePath = "~/.abcd/" + StoreFileName
StorePath is where the interim store lives, displayed with ~ so no developer-identity path reaches output.
Variables ¶
var ErrNotSet = errors.New("credential not set")
ErrNotSet is a credential that resolves to nothing: no store, no entry, or an empty value. It is the one error a caller may treat as "carry on without it".
Functions ¶
func CheckValue ¶
CheckValue refuses a value SetMachine would refuse, without echoing it, so a caller can refuse before any other work.
func SetMachine ¶
SetMachine writes value under name in the interim store at home (~/.abcd/credentials.json): the one write this package makes, for the one home it reads (itd-2609081951381895's setup; the credential store, itd-2609221017023290, brings the other homes and replaces this backing).
It refuses, before writing anything and without echoing either value: a name that is not plain; a value that is empty, longer than MaxValueBytes, padded with white space or carrying a control, bidirectional or zero-width character; a store Resolve would refuse (a symlink, group- or other- readable, not owned by the caller, malformed), so a write never launders an unsafe file; and a name already holding a different value, because a stored secret is never replaced by a second one unasked. The same value already stored is no change (changed is false). The file is written atomically at mode 0600, and ~/.abcd is created owner-only when it is absent. The read, the change and the write hold the store's lock (fsutil.WithFileLock, beside the store), so concurrent writers never lose each other's entries.