internal

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDMPNoDiff = errors.New("DMPNoDiff")
View Source
var ErrLoadObject = errors.New("LoadObject")

Functions

func EscapeCommand added in v0.3.0

func EscapeCommand(command string) string

func HeadString added in v0.4.0

func HeadString(s, sep string, n int) string

func TailString added in v0.4.0

func TailString(s, sep string, n int) string

func YellowString added in v0.5.0

func YellowString(s string) string

Types

type DMP added in v0.4.0

type DMP struct {
	LeftLabel  string
	RightLabel string
	Context    int
}

func (*DMP) Diff added in v0.4.0

func (p *DMP) Diff(left, right string) (*DMPResult, error)

type DMPDiffer added in v0.5.0

type DMPDiffer struct{}

func NewDMPDiffer added in v0.5.0

func NewDMPDiffer() *DMPDiffer

func (*DMPDiffer) Diff added in v0.5.0

func (*DMPDiffer) Diff(ctx context.Context, req *DiffRequest) (*DiffResponse, error)

type DMPHunk added in v0.4.0

type DMPHunk struct {
	Op   DMPOp
	Body string
}

func (*DMPHunk) IntoString added in v0.4.0

func (h *DMPHunk) IntoString(color bool) string

type DMPOp added in v0.4.0

type DMPOp int
const (
	DMPOpEqual DMPOp = iota
	DMPOpDelete
	DMPOpInsert
)

func (DMPOp) Color added in v0.4.0

func (p DMPOp) Color() func(string) string

func (DMPOp) String added in v0.4.0

func (p DMPOp) String() string

type DMPPatch added in v0.4.0

type DMPPatch struct {
	LeftStart   int
	RightStart  int
	LeftLength  int
	RightLength int
	Hunks       []*DMPHunk
}

func (*DMPPatch) IntoString added in v0.4.0

func (p *DMPPatch) IntoString(color bool) string

type DMPResult added in v0.4.0

type DMPResult struct {
	LeftLabel  string
	RightLabel string
	Patches    []*DMPPatch
}

func (*DMPResult) IntoString added in v0.4.0

func (r *DMPResult) IntoString(color bool) string

type DiffRequest added in v0.5.0

type DiffRequest struct {
	LeftLabel  string
	RightLabel string
	Left       string
	Right      string
	Color      bool
	Context    int
}

type DiffResponse added in v0.5.0

type DiffResponse struct {
	Diff string
}

type Differ added in v0.5.0

type Differ interface {
	Diff(ctx context.Context, req *DiffRequest) (*DiffResponse, error)
}

type Marshaler

type Marshaler interface {
	Marshal(ctx context.Context, v any) ([]byte, error)
}

type Object

type Object struct {
	Header ObjectHeader
	Body   string
}

func LoadObjectFromMap

func LoadObjectFromMap(ctx context.Context, marshaler Marshaler, obj map[string]any) (*Object, error)

func LoadObjects

func LoadObjects(ctx context.Context, r io.Reader, marshaler Marshaler, allowDuplicteMapKey bool) ([]*Object, error)

type ObjectDiff

type ObjectDiff struct {
	Pair *ObjectPair
	Diff string
}

type ObjectDiffBuilder

type ObjectDiffBuilder struct {
	// contains filtered or unexported fields
}

func NewObjectDiffBuilder

func NewObjectDiffBuilder(
	differ Differ,
	left, right string,
	diffContext int,
	color bool,

) *ObjectDiffBuilder

func (*ObjectDiffBuilder) ObjectDiff

func (d *ObjectDiffBuilder) ObjectDiff(ctx context.Context, pair *ObjectPair) (*ObjectDiff, error)

type ObjectDiffer

type ObjectDiffer interface {
	ObjectDiff(ctx context.Context, pair *ObjectPair) (*ObjectDiff, error)
}

type ObjectHeader

type ObjectHeader struct {
	APIVersion string     `yaml:"apiVersion"`
	Kind       string     `yaml:"kind"`
	Metadata   ObjectMeta `yaml:"metadata"`
}

ObjectHeader is a seed of the Object ID.

func (ObjectHeader) IntoID

func (s ObjectHeader) IntoID(sep string) string

type ObjectMap

type ObjectMap struct {
	// contains filtered or unexported fields
}

func NewObjectMap

func NewObjectMap(sep string) *ObjectMap

func (*ObjectMap) Add

func (m *ObjectMap) Add(obj *Object) bool

func (*ObjectMap) Get

func (m *ObjectMap) Get(id string) (*Object, bool)

func (*ObjectMap) Keys

func (m *ObjectMap) Keys() []string

type ObjectMeta

type ObjectMeta struct {
	Namespace string `yaml:"namespace"`
	Name      string `yaml:"name"`
}

type ObjectPair

type ObjectPair struct {
	ID    string
	Left  *Object
	Right *Object
}

ObjectPair is a pair of [Objects] that share the same ID.

func (*ObjectPair) IsMissing

func (p *ObjectPair) IsMissing() bool

type ObjectPairMap

type ObjectPairMap struct {
	// contains filtered or unexported fields
}

func NewObjectPairMap

func NewObjectPairMap(left, right *ObjectMap) *ObjectPairMap

func (*ObjectPairMap) ObjectPairs

func (m *ObjectPairMap) ObjectPairs() []*ObjectPair

type ObjectPairer

type ObjectPairer interface {
	ObjectPairs() []*ObjectPair
}

type ProcessDiffer added in v0.5.0

type ProcessDiffer struct {
	// contains filtered or unexported fields
}

func NewProcessDiffer added in v0.5.0

func NewProcessDiffer(command string, args []string) *ProcessDiffer

func (*ProcessDiffer) Diff added in v0.5.0

func (d *ProcessDiffer) Diff(ctx context.Context, req *DiffRequest) (*DiffResponse, error)

type Unmarshaler

type Unmarshaler[T any] interface {
	// Unmarshal reads all documents and unmarshal them as a list of T.
	Unmarshal(ctx context.Context) ([]T, error)
}

type YamlMarshaler

type YamlMarshaler struct {
	// contains filtered or unexported fields
}

func NewYamlMarshaler

func NewYamlMarshaler(indent int, literalStyleIfMultiline bool) *YamlMarshaler

func (*YamlMarshaler) Marshal

func (y *YamlMarshaler) Marshal(ctx context.Context, v any) ([]byte, error)

type YamlUnmarshaler

type YamlUnmarshaler[T any] struct {
	// contains filtered or unexported fields
}

func NewYamlUnmarshaler

func NewYamlUnmarshaler[T any](r io.Reader, t T, allowDuplicateMapKey bool) *YamlUnmarshaler[T]

func (*YamlUnmarshaler[T]) Unmarshal

func (y *YamlUnmarshaler[T]) Unmarshal(ctx context.Context) ([]T, error)

Jump to

Keyboard shortcuts

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