Documentation
¶
Overview ¶
Package envelope provides the standard JSON response wrapper for all --json output.
Index ¶
Constants ¶
const SchemaVersion = "v1"
SchemaVersion is the public contract version. Consumers decoding this envelope should branch on major-version changes (v1 -> v2) and expect additive changes within a version. Adding a field is backward-compatible (unknown fields are ignored by Go's json decoder). Renaming or removing a field is a breaking change and requires a major-version bump.
Variables ¶
var ErrAlreadyWritten = errors.New("error already written to output")
ErrAlreadyWritten signals that an error envelope has already been written to output, so the caller must set a non-zero exit status WITHOUT describing the failure a second time.
It lives here rather than beside one of its users because both the command layer and the query layer produce envelopes and cannot import each other. Before this, only the command layer had a sentinel: the query layer encoded an envelope saying status "error" and returned nil, so `vaultmind note get missing-id --json || handle_failure` never fired.
Functions ¶
func WriteError ¶ added in v0.4.2
WriteError encodes env and returns ErrAlreadyWritten, so that "wrote an error envelope" and "reported success" stop being a state a caller can express. An encoding failure is returned as itself — nothing reached the reader, so there is no envelope for an exit code to agree with.
Types ¶
type Envelope ¶
type Envelope struct {
SchemaVersion string `json:"schema_version"`
Command string `json:"command"`
Status string `json:"status"`
Warnings []Issue `json:"warnings"`
Errors []Issue `json:"errors"`
Result interface{} `json:"result"`
Meta Meta `json:"meta"`
}
Envelope is the standard JSON response wrapper for all --json output.
func (*Envelope) AddWarning ¶
AddWarning adds a structured warning and updates status.