...

Package tree

import "github.com/linkerd/linkerd2/pkg/tree"
Overview
Index

Overview ▾

type Tree

Tree is a structured representation of a string keyed tree document such as yaml or json.

type Tree map[string]interface{}

func BytesToTree

func BytesToTree(bytes []byte) (Tree, error)

BytesToTree converts given bytes into a tree by Unmarshaling

func Diff

func Diff(x interface{}, y interface{}) (Tree, error)

Diff marshals two objects into their yaml representations and then performs a diff on those Trees. It returns a Tree which represents all of the fields in y which differ from x.

func MarshalToTree

func MarshalToTree(obj interface{}) (Tree, error)

MarshalToTree marshals obj to yaml and then parses the resulting yaml as a Tree.

func (Tree) Diff

func (t Tree) Diff(other Tree) (Tree, error)

Diff returns the subset of other where its values differ from t.

func (Tree) Empty

func (t Tree) Empty() bool

Empty returns true iff the Tree contains no leaf values.

func (Tree) GetString

func (t Tree) GetString(path ...string) (string, error)

GetString returns the string value at the given path

func (Tree) Prune

func (t Tree) Prune()

Prune removes all empty subtrees. A subtree is considered empty if it does not contain any leaf values.

func (Tree) String

func (t Tree) String() string

String returns a yaml representation of the Tree or an error string if serialization fails.

func (Tree) ToYAML

func (t Tree) ToYAML() (string, error)

ToYAML returns a yaml serialization of the Tree.