compare

package
v0.0.0-...-32c9531 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReferenceFileName = "metadata.yaml"

	DiffSeparator = "**********************************"
)
View Source
const (
	Json string = "json"
	Yaml        = "yaml"
)

Variables

View Source
var OutputFormats = []string{Json, Yaml}

Functions

func FuncMap

func FuncMap() template.FuncMap

FuncMap returns a mapping of all of the functions that Engine has.

Because some functions are late-bound (e.g. contain context-sensitive data), the functions may not all perform identically outside of an Engine as they will inside of an Engine.

Known late-bound functions:

  • "include"
  • "tpl"

These are late-bound in Engine.Render(). The version included in the FuncMap is a placeholder.

Types

type Component

type Component struct {
	Name              string        `json:"name"`
	Type              ComponentType `json:"type,omitempty"`
	RequiredTemplates []string      `json:"requiredTemplates,omitempty"`
	OptionalTemplates []string      `json:"optionalTemplates,omitempty"`
}

type ComponentType

type ComponentType string
const (
	Required ComponentType = "Required"
	Optional               = "Optional"
)

type Corelator

type Corelator interface {
	Match(*unstructured.Unstructured) (*template.Template, error)
}

Corelator provides an abstraction that allow the usage of different Resource correlation logics in the kubectl cluster-compare. The correlation process Matches for each Resource a template.

type CorrelationSettings

type CorrelationSettings struct {
	ManualCorrelation ManualCorrelation `json:"manualCorrelation"`
}

type DiffSum

type DiffSum struct {
	DiffOutput         string `json:"DiffOutput"`
	CorrelatedTemplate string `json:"CorrelatedTemplate"`
	CRName             string `json:"CRName"`
}

DiffSum Contains the diff output and correlation info of a specific CR

func (DiffSum) String

func (s DiffSum) String() string

type ExactMatchCorelator

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

ExactMatchCorelator Matches templates by exact match between a predefined config including pairs of Resource names and there equivalent template. The names of the resources are in the apiVersion-kind-namespace-name format. For fields that are not namespaced apiVersion-kind-name format will be used.

func NewExactMatchCorelator

func NewExactMatchCorelator(crToTemplate map[string]string, templates []*template.Template) (*ExactMatchCorelator, error)

func (ExactMatchCorelator) Match

type GroupCorelator

type GroupCorelator struct {

	//List of Hash functions for groups of fields organized in same order of fieldGroups
	GroupFunctions []func(unstructured2 *unstructured.Unstructured) (group string, err error)
	// contains filtered or unexported fields
}

GroupCorelator Matches templates by hashing predefined fields. All The templates are indexed by hashing groups of `indexed` fields. The `indexed` fields can be nested. Resources will be attempted to be matched with hashing by the group with the largest amount of `indexed` fields. In case a Resource Matches by a hash a group of templates the group corelator will continue looking for a match (with groups with less `indexed fields`) until it finds a distinct match, in case it doesn't, MultipleMatches error will be returned. Templates will be only indexed by a group of fields only if all fields in group are not templated.

func NewGroupCorelator

func NewGroupCorelator(fieldGroups [][][]string, templates []*template.Template) (*GroupCorelator, error)

NewGroupCorelator creates a new GroupCorelator using inputted fieldGroups and generated GroupFunctions and templatesByGroups. The templates will be divided into different kinds of groups based on the fields that are templated. Templates will be added to the kind of group that contains the biggest amount of fully defined `indexed` fields. For fieldsGroups = {{{"metadata", "namespace"}, {"kind"}}, {{"kind"}}} and the following templates: [fixedKindTemplate, fixedNamespaceKindTemplate] the fixedNamespaceKindTemplate will be added to a mapping where the keys are in the format of `namespace_kind`. The fixedKindTemplate will be added to a mapping where the keys are in the format of `kind`.

func (*GroupCorelator) Match

type HTTPFS

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

HTTPFS represents a file system that retrieves files from a http server by returning the http response body, ideal for http servers that return raw files

func (HTTPFS) Open

func (fs HTTPFS) Open(name string) (fs.File, error)

Open creates a http request and returns a http body reader object representing a file for reading.

type HTTPFile

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

HTTPFile represents a file obtained from an HTTP response body.

func (HTTPFile) Close

func (f HTTPFile) Close() error

Close closes the http body reader.

func (HTTPFile) Read

func (f HTTPFile) Read(b []byte) (int, error)

Read returns the http body.

func (HTTPFile) Stat

func (f HTTPFile) Stat() (fs.FileInfo, error)

Stat returns the HTTP file information.

type HTTPFileInfo

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

HTTPFileInfo represents information about the http raw resource

func (HTTPFileInfo) IsDir

func (f HTTPFileInfo) IsDir() bool

IsDir abbreviation for Mode().IsDir()

func (HTTPFileInfo) ModTime

func (f HTTPFileInfo) ModTime() time.Time

ModTime returns the time of the http response

func (HTTPFileInfo) Mode

func (f HTTPFileInfo) Mode() fs.FileMode

Mode returns the file mode bits - always returns fs.ModeTemporary because file isn't in local file system and is a http resource

func (HTTPFileInfo) Name

func (f HTTPFileInfo) Name() string

Name returns the uri of the file from the requested base URL

func (HTTPFileInfo) Size

func (f HTTPFileInfo) Size() int64

Size returns the length of the http body

func (HTTPFileInfo) Sys

func (f HTTPFileInfo) Sys() any

Sys underlying data source - returns nil

type InfoObject

type InfoObject struct {
	FieldsToOmit [][]string
	// contains filtered or unexported fields
}

InfoObject matches the diff.Object interface, it contains the objects that shall be compared.

func (InfoObject) Live

func (obj InfoObject) Live() runtime.Object

Live Returns the cluster version of the object

func (InfoObject) Merged

func (obj InfoObject) Merged() (runtime.Object, error)

Merged Returns the Injected Reference Version of the Resource

func (InfoObject) Name

func (obj InfoObject) Name() string

type ManualCorrelation

type ManualCorrelation struct {
	CorrelationPairs map[string]string `json:"correlationPairs"`
}

type MetricsCorelatorDecorator

type MetricsCorelatorDecorator struct {
	UnMatchedCRs []*unstructured.Unstructured

	MatchedTemplatesNames map[string]bool
	// contains filtered or unexported fields
}

MetricsCorelatorDecorator Matches templates by using an existing correlator and gathers summary info related the correlation.

func NewMetricsCorelatorDecorator

func NewMetricsCorelatorDecorator(corelator Corelator, parts []Part, errsToIgnore []error) *MetricsCorelatorDecorator

func (*MetricsCorelatorDecorator) Match

type MultiCorelator

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

MultiCorelator Matches templates by attempting to find a match with one of its predefined Corelators.

func NewMultiCorealtor

func NewMultiCorealtor(corelators []Corelator) *MultiCorelator

func (MultiCorelator) Match

type MultipleMatches

type MultipleMatches struct {
	Resource *unstructured.Unstructured
	Matches  []*template.Template
}

MultipleMatches an error that can be returned by a Corelator in a case multiple template Matches were found for a Resource.

func (MultipleMatches) Error

func (e MultipleMatches) Error() string

type Options

type Options struct {
	CRs resource.FilenameOptions

	ShowManagedFields bool
	OutputFormat      string

	Concurrency int

	genericiooptions.IOStreams
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions(ioStreams genericiooptions.IOStreams) *Options

func (*Options) Complete

func (o *Options) Complete(f kcmdutil.Factory, cmd *cobra.Command, args []string) error

func (*Options) Run

func (o *Options) Run() error

Run uses the factory to parse file arguments (in case of local mode) or gather all cluster resources matching templates types. For each Resource it finds the matching Resource template and injects, compares, and runs against differ.

type Output

type Output struct {
	Summary *Summary   `json:"Summary"`
	Diffs   *[]DiffSum `json:"Diffs"`
}

Output Contains the complete output of the command

func (Output) Print

func (o Output) Print(format string, out io.Writer) (int, error)

func (Output) String

func (o Output) String() string

type Part

type Part struct {
	Name       string      `json:"name"`
	Components []Component `json:"components"`
}

type Reference

type Reference struct {
	Parts                 []Part     `json:"parts"`
	TemplateFunctionFiles []string   `json:"templateFunctionFiles,omitempty"`
	FieldsToOmit          [][]string `json:"fieldsToOmit,omitempty"`
}

type Summary

type Summary struct {
	RequiredCRS  map[string]map[string][]string `json:"RequiredCRS"`
	NumMissing   int                            `json:"NumMissing"`
	UnmatchedCRS []string                       `json:"UnmatchedCRS"`
	NumDiffCRs   int                            `json:"NumDiffCRs"`
}

Summary Contains all info included in the Summary output of the compare command

func (Summary) String

func (s Summary) String() string

type UnknownMatch

type UnknownMatch struct {
	Resource *unstructured.Unstructured
}

UnknownMatch an error that can be returned by a Corelator in a case no template was matched for a Resource.

func (UnknownMatch) Error

func (e UnknownMatch) Error() string

type UserConfig

type UserConfig struct {
	CorrelationSettings CorrelationSettings `json:"correlationSettings"`
}

Jump to

Keyboard shortcuts

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