Documentation
¶
Overview ¶
Package stackedit holds the shared primitives for mutating stack.yaml safely: comment-preserving yaml.Node appends, per-path in-process locking, and crash-safe atomic writes. Both the API server's stack editors and the import CLI build on these so there is exactly one write discipline.
Index ¶
- Variables
- func AppendResources(source []byte, key string, snippets ...[]byte) ([]byte, error)
- func AtomicWrite(path string, data []byte) error
- func PathLock(path string) *sync.Mutex
- func RemoveLinkEntry(source []byte, client string) ([]byte, error)
- func RemoveResourceByName(source []byte, key, name string) ([]byte, error)
- func UpsertLinkEntry(source []byte, entry config.LinkEntry) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoLinkBlock = errors.New("no link block in stack") ErrEntryNotDeclared = errors.New("client not declared in link block") )
Sentinel errors for link-block edits, so callers can distinguish expected states (nothing declared) from a stack file that failed to parse.
Functions ¶
func AppendResources ¶
AppendResources appends one or more mapping snippets to the top-level sequence at key in source, in order. The yaml.Node round-trip preserves comments, key ordering, and unrelated formatting; a canonical re-emit from a Go struct would lose all three. Each snippet must parse to a single mapping. A null-valued or absent target sequence is replaced with a fresh sequence in place.
func AtomicWrite ¶
AtomicWrite writes data to path via a same-directory temp file + fsync + rename. A mid-write crash leaves the original file intact; a mid-rename crash on a POSIX filesystem leaves either the old or the new file at path, never a truncated mix. The original file's permissions are preserved.
func RemoveLinkEntry ¶
RemoveLinkEntry removes the entry for client from the top-level link: sequence. When the last entry goes, the link: key is dropped entirely so the file does not carry an empty block. Returns an error when the block or the entry is absent.
func RemoveResourceByName ¶
RemoveResourceByName removes the entry whose name: field equals name from the top-level sequence at key, preserving comments and ordering elsewhere. Returns an error when the sequence or the named entry is absent.
func UpsertLinkEntry ¶
UpsertLinkEntry adds or replaces the entry for entry.Client in the top-level link: sequence, preserving comments, ordering, and the form of untouched entries. The link: sequence mixes scalar shorthands ("- cursor") and mappings; a slug-only entry is emitted back as the scalar form. The key is created when absent.
Types ¶
This section is empty.