Documentation
¶
Overview ¶
Package topicyaml edits a topic's topic.yaml at the yaml.Node level so every key, comment and key order that the caller does not touch survives a write. Both internal/topic (metadata) and internal/contract (contract, drafts, decisions block) write through it.
Index ¶
- Constants
- func Delete(mapping *yaml.Node, key string) bool
- func Get(mapping *yaml.Node, key string) *yaml.Node
- func Mapping(mapping *yaml.Node, key string) (*yaml.Node, error)
- func Set(mapping *yaml.Node, key string, value any) error
- func SetNode(mapping *yaml.Node, key string, node *yaml.Node)
- func Update(path string, edit func(root *yaml.Node) error) error
- func WriteFileAtomic(path string, content []byte) error
- type Document
Constants ¶
const FileName = "topic.yaml"
FileName is the topic metadata file name.
Variables ¶
This section is empty.
Functions ¶
func Mapping ¶
Mapping returns the mapping stored under key, creating an empty one when the key is missing or null. A non-mapping value is an error.
func Set ¶
Set encodes value and stores it under key, replacing the existing value in place (the key node and its comments are kept) or appending the key.
func WriteFileAtomic ¶
WriteFileAtomic writes content to a temporary file next to path and renames it into place, keeping the existing file mode (0644 for new files).
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document is a parsed topic.yaml whose root is always a mapping node.
func Load ¶
Load reads path into a Document. A missing or empty file yields an empty mapping. A file whose root is not a mapping is an error.