journalspace

package
v2.0.209+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package journalspace provides mechanisms for mapping a collection of JournalSpecs into a minimally-described hierarchical structure, and for mapping back again. This is principally useful for tooling over JournalSpecs, which must be written to (& read from) Etcd in fully-specified and explicit form (a representation which is great for implementors, but rather tedious for cluster operators to work with). Tooling can map JournalSpecs into a tree, allow the operator to apply edits in that hierarchical space, and then flatten resulting changes for storage back to Etcd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	// Comment is a no-op field which allows tooling to generate and pass-through
	// comments in written YAML output.
	Comment string `yaml:",omitempty"`
	// Delete marks that a Node, and all Nodes which it parents, should be deleted.
	Delete *bool `yaml:",omitempty"`
	// JournalSpec of the Node, which may be partial and incomplete. Specs apply
	// hierarchically, where Nodes having zero-valued fields inherit those of
	// their parent, and parent Nodes may only have a subset of fields specified.
	// A Node is understood to be a "directory" Node if it ends in a slash '/',
	// and a literal or terminal Node otherwise.
	Spec pb.JournalSpec `yaml:",omitempty,inline"`
	// Revision of the Journal within Etcd. Non-zero for non-directory Nodes only.
	Revision int64 `yaml:",omitempty"`
	// Children of this Node. Directory Nodes must have one or more Children, and
	// non-directory terminal Nodes may not have any.
	Children []Node `yaml:",omitempty"`
	// contains filtered or unexported fields
}

Node represents a collection of JournalSpecs which are related by hierarchical path components, and which may share common portions of their journal specifications.

func FromListResponse

func FromListResponse(resp *pb.ListResponse) Node

FromListResponse builds a tree from a ListResponse, and returns its root Node.

func (*Node) Hoist

func (n *Node) Hoist()

Hoist recursively hoists specification values which are common across each of a Node's children into the Node itself. Hoisted values are then zeroed at each of the Node's children.

func (Node) IsDir

func (n Node) IsDir() bool

IsDir returns whether the Node.JournalSpec.Name is empty or ends in a slash ('/').

func (*Node) MarkUnpatchedForDeletion

func (n *Node) MarkUnpatchedForDeletion()

MarkUnpatchedForDeletion sets Delete for each terminal Node of the tree which has not been Patched.

func (*Node) Patch

func (n *Node) Patch(p Node) *Node

Patch |p| into the tree rooted by the Node, inserting it if required and otherwise updating with fields of |p| which are not zero-valued. Patch returns a reference to the patched *Node, which may also be inspected and updated directly. However, note the returned *Node is invalidated with the next call to Patch.

func (*Node) PushDown

func (n *Node) PushDown()

PushDown specification values from parent Nodes to children, recursively copying fields from parent to child where the child field is zero-valued. After PushDownSpecs, the hierarchically-implied configuration of each terminal made explicit in the representation of that Node.

func (*Node) Validate

func (n *Node) Validate() error

Validate returns an error if the Node hierarchy is not well formed. Note that Validate does *not* also Validate contained JournalSpecs, as partial or incomplete JournalSpecs are permitted within a Node hierarchy. They must be checked separately.

func (*Node) WalkTerminalNodes

func (n *Node) WalkTerminalNodes(cb func(*Node) error) error

WalkTerminalNodes invokes the callback for each of the terminal Nodes of the tree. A returned error aborts the recursive walk, and is returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL