tony

package module
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 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
git-issue command
git-issue/issuelib
Package issuelib provides the core library for git-issue.
Package issuelib provides the core library for git-issue.
o command
tony-codegen command
tony-lsp command
Package debug provides debugging utilities for Tony development.
Package debug provides debugging utilities for Tony development.
Package dirbuild interprets a tony build directory
Package dirbuild interprets a tony build directory
Package encode encodes IR nodes to Tony format text.
Package encode encodes IR nodes to Tony format text.
Package eval provides expression evaluation for Tony documents.
Package eval provides expression evaluation for Tony documents.
Package format provides formatting utilities for Tony documents.
Package format provides formatting utilities for Tony documents.
Package gomap provides encoding and decoding between IR nodes and Go values.
Package gomap provides encoding and decoding between IR nodes and Go values.
codegen
Package codegen generates Go code for Tony schema types.
Package codegen generates Go code for Tony schema types.
ir
Package ir provides the intermediate representation for Tony format documents.
Package ir provides the intermediate representation for Tony format documents.
kpath
Package kpath provides kinded path parsing and navigation.
Package kpath provides kinded path parsing and navigation.
Package libdiff provides diff computation for Tony documents.
Package libdiff provides diff computation for Tony documents.
Package mergeop provides match and patch operations for Tony documents.
Package mergeop provides match and patch operations for Tony documents.
Package parse parses Tony format text into IR nodes.
Package parse parses Tony format text into IR nodes.
Package schema provides Tony Schema for describing and validating Tony documents.
Package schema provides Tony Schema for describing and validating Tony 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/api
Package api provides HTTP API types for the logd server.
Package api provides HTTP API types for the logd server.
logd/server
Package server provides the HTTP server implementation for logd.
Package server provides the HTTP server implementation for logd.
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.
logd/storage/index
Package index provides hierarchical path-based indexing for storage.
Package index provides hierarchical path-based indexing for storage.
logd/storage/internal/dlog
Package dlog provides double-buffered write-ahead logging.
Package dlog provides double-buffered write-ahead logging.
logd/storage/internal/patches
Package patches provides streaming patch application for snapshots.
Package patches provides streaming patch application for snapshots.
logd/storage/internal/seq
Package seq provides atomic sequence counters.
Package seq provides atomic sequence counters.
logd/storage/internal/snap
Package snap provides event-based snapshot storage.
Package snap provides event-based snapshot storage.
logd/storage/tx
Package tx provides transaction coordination for multi-participant updates.
Package tx provides transaction coordination for multi-participant updates.
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