diff

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintFull

func PrintFull(results []Result)

PrintFull prints out a table and the raw diffs for a results slice.

func PrintSummary

func PrintSummary(results []Result)

PrintSummary prints out a summary table for a results slice.

func ResultsTable

func ResultsTable(results []Result) string

ResultsTable returns a table that summarizes a slice of result diffs.

Types

type DiffConfig

type DiffConfig struct {
	ContextLines  int
	MaxLineLength int
	MaxSize       int
}

DiffConfig configures how Kubernetes diffs should be generated.

type Operation

type Operation string

Operation describes whether a diff block represents a creation, deletion, or update.

const (
	OperationCreate Operation = "create"
	OperationDelete Operation = "delete"
	OperationUpdate Operation = "update"
)

type Result

type Result struct {
	Object     *apply.TypedKubeObj `json:"object"`
	Name       string              `json:"name"`
	RawDiff    string              `json:"rawDiff"`
	NumAdded   int                 `json:"numAdded"`
	NumRemoved int                 `json:"numRemoved"`
	Operation  Operation           `json:"operation"`
}

Result contains the results of diffing a single object.

func DiffKube

func DiffKube(
	oldRoot string,
	newRoot string,
	config DiffConfig,
) ([]Result, error)

DiffKube processes the results of a kubectl diff call in place of the default 'diff' command.

func (*Result) ClippedRawDiff

func (r *Result) ClippedRawDiff(maxLen int) string

ClippedRawDiff returns a clipped version of the raw diff for this result. Used in the Github diff comment template.

func (*Result) NumChangedLines

func (r *Result) NumChangedLines() int

NumChangedLines returns the rough number of lines changed (taken as the max of the num added and num removed).

func (*Result) PrintRaw

func (r *Result) PrintRaw()

PrintRaw prints out the raw diffs for a single resource.

type Results

type Results struct {
	Results []Result `json:"results"`
}

Results contains all results from a given diff run. It's used for wrapping so that everything can be put in a single struct when exported by kubeapply kdiff.

Jump to

Keyboard shortcuts

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