tony

package module
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

README

Tony Format

Tony package houses the reference implementation of the Tony Format and several related tools.

O

o is a tool for managing objects stored in formats like Tony, YAML, and JSON.

Overview
# view files 
o view [ -color ] file [-e path=value ]
o v [ -color ] [-e path=value ] < file
# process a file with embedded transformation instructions
o eval file [-e path=value ] [ files... ]
o e [-e path=value ] < file
# path querys
o list '$...a[*]' [ files... ]
o l '$...a[*]' [ files... ]
o get '$.a[1]' [ files... ]
o g '$.a[1]' [ files... ]
# compute a diff between -- understands tags and strings and arrays!
o diff file1 file2
# match secrets and config maps
kustomize build . | o -y match -s '{ kind: !or [ ConfigMap, Secret] }' -
helm template . | o -y match -s '{ kind: !or [ ConfigMap, Secret] }' -
# patch a file -- understands tags and strings and arrays and diffs,
# all in merge patch style!
o patch -p patch [ file ]
# build manifests and helm charts with matches and patches and embedded transformations
o build [ manifest-build/] [ -l ]  [ -p profile ] [ -e path=value ] [-- path1=value1 path2=value2 ... ]
o b [ manifest-build/] [ -l ]  [ -p profile ] [ -s ] [ -e path=value ]

Documentation

Overview

Package tony provides support and tooling for the Tony format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(from, to *ir.Node) *ir.Node

Diff produces a succint comparison of from and to. If there are no differences, Diff returns nil.

A resulting diff may be reversed using libdiff.Reverse.

A resulting diff may be used as a patch in Patch.

The structure returned by Diff contains a minimal set of changes indicated by yaml tags which double as patch operations.

  • if the types of from and to differ then the result is a node !replace from: from to: to

  • for ObjectType any field f in to but not in from has a field `f: !delete[(<orig-tag>)] ...`

  • for ObjectType any field f in from but not in to has a field `f: !insert[(<orig-tag>)] ...`

  • for any field f shared by from and to which is equal, it is absent in the result.

  • for any field f with a difference, it contains a diff of the value of f in from and respectively to.

For ArrayType nodes which differ, if both nodes are tagged by the same key with !key(<key>), they are treated as objects but presented as an array with tag !key(<key>).

For StringTypes, a string diff may computed and if the size of the string diff is less than half the size of the the smallest string

If only the tags differ, the tags !addtag(<tag>) !rmtag(<tag>) and !retag(<from>,<to>) will be present decorating a null.

func Match

func Match(doc, match *ir.Node) (bool, error)

func Patch

func Patch(doc, patch *ir.Node) (*ir.Node, error)

func Trim

func Trim(match, doc *ir.Node) *ir.Node

Trim filters a document to only include fields/values that are present in the match criteria. It recursively processes objects and arrays, removing fields that aren't in the match. The result preserves the tag from the original document.

Types

type DiffConfig

type DiffConfig struct {
	Comments bool
}

type DiffOpt

type DiffOpt func(*DiffConfig)

func DiffComments

func DiffComments(v bool) DiffOpt

type MatchConfig

type MatchConfig struct {
	Comments bool
	Tags     bool
}

type MatchOpt

type MatchOpt func(*MatchConfig)

func MatchComments

func MatchComments(v bool) MatchOpt

func MatchTags

func MatchTags(v bool) MatchOpt

type PatchConfig

type PatchConfig struct {
	Comments bool
}

type PatchOpt

type PatchOpt func(*PatchConfig)

func PatchComments

func PatchComments(v bool) PatchOpt

type Tool

type Tool struct {
	Env map[string]any
}

func DefaultTool

func DefaultTool() *Tool

func (*Tool) Run

func (t *Tool) Run(y *ir.Node) (*ir.Node, error)

Directories

Path Synopsis
cmd
o command
tony-codegen command
tony-lsp command
Package dirbuild interprets a tony build directory
Package dirbuild interprets a tony build directory
Package ir provides the intermediate representation (IR) for Tony format documents.
Package ir provides the intermediate representation (IR) for Tony format documents.
Package mergeop provides operations for matching and patching Tony format documents.
Package mergeop provides operations for matching and patching Tony format documents.
Package schema provides support for Tony Schema, a schema system for describing and validating Tony format documents.
Package schema provides support for Tony Schema, a schema system for describing and validating Tony format documents.
Package stream provides streaming encode/decode for Tony documents.
Package stream provides streaming encode/decode for Tony documents.
system
logd
Package logd provides the backend storage for the tony system api.
Package logd provides the backend storage for the tony system api.
logd/storage
Package storage provides a filesystem based storage layer for tony system api.
Package storage provides a filesystem based storage layer for tony system api.
Package token provides tokenization support for Tony and related formats.
Package token provides tokenization support for Tony and related formats.

Jump to

Keyboard shortcuts

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