compare

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 42 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DiffSeparator = "**********************************\n"

	DiffsFoundMsg = "there are differences between the cluster CRs and the reference CRs"
)
View Source
const (
	Json      string = "json"
	Yaml      string = "yaml"
	PatchYaml string = "generate-patches"
)
View Source
const (
	MissingCRsMsg      = "Missing CRs"
	MatchedMoreThanOne = "Should only match one but matched"
)
View Source
const ReferenceVersionV1 string = "v1"
View Source
const ReferenceVersionV2 string = "v2"

Variables

View Source
var FieldSeparator = "_"
View Source
var InlineDiffs = map[inlineDiffType]InlineDiff{
	// contains filtered or unexported fields
}
View Source
var OutputFormats = []string{Json, Yaml, PatchYaml}

Functions

func CapturegroupQuoteMeta added in v0.3.0

func CapturegroupQuoteMeta(pattern string, groups []CgInfo) string

Transforms all non-capturegroup text in the pattern via Regex.QuoteMeta(), reusing previously-computed group indices Additionally this will add appropriate word or end-of-string anchors to capturegroups and/or the whole pattern according to the global 'quoteEscapeFull' option

func FromYAML added in v0.0.2

func FromYAML(str string) map[string]any

FromYAML converts a YAML document into a map[string]any.

This is not a general-purpose YAML parser, and will not parse all valid YAML documents. Additionally, because its intended use is within templates it tolerates errors. It will insert the returned error message string into m["Error"] in the returned map.

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.

func GetRefFS added in v0.0.2

func GetRefFS(refConfig string) (fs.FS, error)

func MergeManifests added in v0.0.2

func MergeManifests(localRef, clusterCR *unstructured.Unstructured) (updateLocalRef *unstructured.Unstructured, err error)

MergeManifests will return an attempt to update the localRef with the clusterCR. In the case of an error it will return an unmodified localRef.

Types

type AllOf added in v0.1.1

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

func (*AllOf) GetTemplates added in v0.1.1

func (g *AllOf) GetTemplates() []*ReferenceTemplateV2

func (*AllOf) SetTemplates added in v0.1.1

func (g *AllOf) SetTemplates(t []*ReferenceTemplateV2)

func (*AllOf) UnmarshalJSON added in v0.1.1

func (g *AllOf) UnmarshalJSON(b []byte) (err error)

type AllOrNoneOf added in v0.1.1

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

func (*AllOrNoneOf) GetTemplates added in v0.1.1

func (g *AllOrNoneOf) GetTemplates() []*ReferenceTemplateV2

func (*AllOrNoneOf) SetTemplates added in v0.1.1

func (g *AllOrNoneOf) SetTemplates(t []*ReferenceTemplateV2)

func (*AllOrNoneOf) UnmarshalJSON added in v0.1.1

func (g *AllOrNoneOf) UnmarshalJSON(b []byte) (err error)

type AnyOf added in v0.1.1

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

func (*AnyOf) GetTemplates added in v0.1.1

func (g *AnyOf) GetTemplates() []*ReferenceTemplateV2

func (*AnyOf) SetTemplates added in v0.1.1

func (g *AnyOf) SetTemplates(t []*ReferenceTemplateV2)

func (*AnyOf) UnmarshalJSON added in v0.1.1

func (g *AnyOf) UnmarshalJSON(b []byte) (err error)

type AnyOneOf added in v0.1.1

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

func (*AnyOneOf) GetTemplates added in v0.1.1

func (g *AnyOneOf) GetTemplates() []*ReferenceTemplateV2

func (*AnyOneOf) SetTemplates added in v0.1.1

func (g *AnyOneOf) SetTemplates(t []*ReferenceTemplateV2)

func (*AnyOneOf) UnmarshalJSON added in v0.1.1

func (g *AnyOneOf) UnmarshalJSON(b []byte) (err error)

type CRMetadata added in v0.3.0

type CRMetadata struct {
	Description string `json:"description,omitempty"`
}

type CapturegroupsInlineDiff added in v0.3.0

type CapturegroupsInlineDiff struct{}

func (CapturegroupsInlineDiff) Diff added in v0.3.0

func (id CapturegroupsInlineDiff) Diff(pattern, value string) string

Main entrypoint called by compare.go

func (CapturegroupsInlineDiff) Validate added in v0.3.0

func (id CapturegroupsInlineDiff) Validate(pattern string) error

Validation entrypoint called by referenceV2.go

type CgInfo added in v0.3.0

type CgInfo struct {
	Name  string
	Start int
	End   int
}

func CapturegroupIndex added in v0.3.0

func CapturegroupIndex(pattern string) []CgInfo

Return a list of the valid-looking capturegroup indices within the given pattern string. Each inner list is a tuple of start:end indices that can be used to extract a capture group. For example:

groups := CaptureGroupIndex(pattern)
loc := groups[0]
cg := pattern[loc[0],loc[1]]

type ComponentTypeV1 added in v0.1.1

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

type ComponentV1 added in v0.1.1

type ComponentV1 struct {
	Name              string                 `json:"name"`
	Type              ComponentTypeV1        `json:"type,omitempty"`
	RequiredTemplates []*ReferenceTemplateV1 `json:"requiredTemplates,omitempty"`
	OptionalTemplates []*ReferenceTemplateV1 `json:"optionalTemplates,omitempty"`
}

type ComponentV2 added in v0.1.1

type ComponentV2 struct {
	Name        string `json:"name"`
	OneOf       `json:"oneOf,omitempty"`
	NoneOf      `json:"noneOf,omitempty"`
	AllOf       `json:"allOf,omitempty"`
	AnyOf       `json:"anyOf,omitempty"`
	AnyOneOf    `json:"anyOneOf,omitempty"`
	AllOrNoneOf `json:"allOrNoneOf,omitempty"`
	// contains filtered or unexported fields
}

type ComponentV2Group added in v0.1.1

type ComponentV2Group interface {
	SetTemplates([]*ReferenceTemplateV2)
	GetTemplates() []*ReferenceTemplateV2
	UnmarshalJSON([]byte) (err error)
	// contains filtered or unexported methods
}

type CorrelationEntry added in v0.1.1

type CorrelationEntry interface {
	GetIdentifier() string
	GetMetadata() *unstructured.Unstructured
}

type CorrelationSettings

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

type Correlator

type Correlator[T CorrelationEntry] interface {
	Match(*unstructured.Unstructured) ([]T, error)
}

Correlator 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 DiffSum

type DiffSum struct {
	DiffOutput         string   `json:"DiffOutput"`
	CorrelatedTemplate string   `json:"CorrelatedTemplate"`
	CRName             string   `json:"CRName"`
	Patched            string   `json:"Patched,omitempty"`
	OverrideReasons    []string `json:"OverrideReason,omitempty"`
	Description        string   `json:"description,omitempty"`
}

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

func (DiffSum) HasDiff

func (s DiffSum) HasDiff() bool

func (DiffSum) String

func (s DiffSum) String() string

func (DiffSum) WasPatched added in v0.1.1

func (s DiffSum) WasPatched() bool

type ExactMatchCorrelator

type ExactMatchCorrelator[T CorrelationEntry] struct {
	// contains filtered or unexported fields
}

ExactMatchCorrelator 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 NewExactMatchCorrelator

func NewExactMatchCorrelator[T CorrelationEntry](matchPairs map[string]string, templates []T) (*ExactMatchCorrelator[T], error)

func (ExactMatchCorrelator[T]) Match

func (c ExactMatchCorrelator[T]) Match(object *unstructured.Unstructured) ([]T, error)

type FieldCorrelator

type FieldCorrelator[T CorrelationEntry] struct {
	Fields [][]string
	// contains filtered or unexported fields
}

func (*FieldCorrelator[T]) ClaimTemplates

func (f *FieldCorrelator[T]) ClaimTemplates(templates []T) []T

func (FieldCorrelator[T]) Match

func (f FieldCorrelator[T]) Match(object *unstructured.Unstructured) ([]T, error)

func (*FieldCorrelator[T]) ValidateTemplates

func (f *FieldCorrelator[T]) ValidateTemplates() error

type FieldsToOmit

type FieldsToOmit interface {
	GetDefault() string
	GetItems() map[string][]*ManifestPathV1
}

type FieldsToOmitV1 added in v0.1.1

type FieldsToOmitV1 struct {
	DefaultOmitRef string                       `json:"defaultOmitRef,omitempty"`
	Items          map[string][]*ManifestPathV1 `json:"items,omitempty"`
}

func (*FieldsToOmitV1) GetDefault added in v0.1.1

func (toOmit *FieldsToOmitV1) GetDefault() string

func (*FieldsToOmitV1) GetItems added in v0.1.1

func (toOmit *FieldsToOmitV1) GetItems() map[string][]*ManifestPathV1

type FieldsToOmitV2 added in v0.2.0

type FieldsToOmitV2 struct {
	DefaultOmitRef string                            `json:"defaultOmitRef,omitempty"`
	Items          map[string][]*FieldsToOmitV2Entry `json:"items,omitempty"`
	// contains filtered or unexported fields
}

func (*FieldsToOmitV2) GetDefault added in v0.2.0

func (toOmit *FieldsToOmitV2) GetDefault() string

func (*FieldsToOmitV2) GetItems added in v0.2.0

func (toOmit *FieldsToOmitV2) GetItems() map[string][]*ManifestPathV1

type FieldsToOmitV2Entry added in v0.2.0

type FieldsToOmitV2Entry struct {
	*ManifestPathV1
	Include string `json:"include,omitempty"`
	// contains filtered or unexported fields
}

type GroupCorrelator

type GroupCorrelator[T CorrelationEntry] struct {
	// contains filtered or unexported fields
}

GroupCorrelator 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 correlator 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 NewGroupCorrelator

func NewGroupCorrelator[T CorrelationEntry](fieldGroups [][][]string, objects []T) (*GroupCorrelator[T], error)

NewGroupCorrelator creates a new GroupCorrelator 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 (*GroupCorrelator[T]) Match

func (c *GroupCorrelator[T]) Match(object *unstructured.Unstructured) ([]T, error)

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 []*ManifestPathV1
	// 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 InlineDiff added in v0.3.0

type InlineDiff interface {
	Diff(templateValue, crValue string) string
	Validate(templateValue string) error
}

type InlineDiffError added in v0.3.0

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

func (InlineDiffError) Error added in v0.3.0

func (e InlineDiffError) Error() string

type ManifestPathV1 added in v0.1.1

type ManifestPathV1 struct {
	PathToKey string `json:"pathToKey"`
	IsPrefix  bool   `json:"isPrefix,omitempty"`
	// contains filtered or unexported fields
}

func (*ManifestPathV1) Process added in v0.1.1

func (p *ManifestPathV1) Process() error

type ManualCorrelation

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

type MergeError

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

func (MergeError) Error

func (e MergeError) Error() string

type MetricsTracker added in v0.0.2

type MetricsTracker struct {
	UnMatchedCRs []*unstructured.Unstructured

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

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

func NewMetricsTracker added in v0.0.2

func NewMetricsTracker() *MetricsTracker

type MultiCorrelator

type MultiCorrelator[T CorrelationEntry] struct {
	// contains filtered or unexported fields
}

MultiCorrelator Matches templates by attempting to find a match with one of its predefined Correlators.

func NewMultiCorrelator

func NewMultiCorrelator[T CorrelationEntry](correlators []Correlator[T]) *MultiCorrelator[T]

func (MultiCorrelator[T]) Match

func (c MultiCorrelator[T]) Match(object *unstructured.Unstructured) ([]T, error)

type NoneOf added in v0.1.1

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

func (*NoneOf) GetTemplates added in v0.1.1

func (g *NoneOf) GetTemplates() []*ReferenceTemplateV2

func (*NoneOf) SetTemplates added in v0.1.1

func (g *NoneOf) SetTemplates(t []*ReferenceTemplateV2)

func (*NoneOf) UnmarshalJSON added in v0.1.1

func (g *NoneOf) UnmarshalJSON(b []byte) (err error)

type OneOf added in v0.1.1

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

func (*OneOf) GetTemplates added in v0.1.1

func (g *OneOf) GetTemplates() []*ReferenceTemplateV2

func (*OneOf) SetTemplates added in v0.1.1

func (g *OneOf) SetTemplates(t []*ReferenceTemplateV2)

func (*OneOf) UnmarshalJSON added in v0.1.1

func (g *OneOf) UnmarshalJSON(b []byte) (err error)

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"`
	// contains filtered or unexported fields
}

Output Contains the complete output of the command

func (Output) Print

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

func (Output) String

func (o Output) String(showEmptyDiffs bool) string

type PartV1 added in v0.1.1

type PartV1 struct {
	Name       string        `json:"name"`
	Components []ComponentV1 `json:"components"`
}

type PartV2 added in v0.1.1

type PartV2 struct {
	Name       string         `json:"name"`
	Components []*ComponentV2 `json:"components"`
}

type PerFieldConfigV2 added in v0.3.0

type PerFieldConfigV2 struct {
	PathToKey      string         `json:"pathToKey,omitempty"`
	InlineDiffFunc inlineDiffType `json:"inlineDiffFunc,omitempty"`
}

type Reference

type Reference interface {
	GetAPIVersion() string
	GetTemplates() []ReferenceTemplate
	GetValidationIssues(matchedTemplates map[string]int) (map[string]map[string]ValidationIssue, int)
	GetFieldsToOmit() FieldsToOmit
	GetTemplateFunctionFiles() []string
}

func GetReference added in v0.0.2

func GetReference(fsys fs.FS, referenceFileName string) (Reference, error)

type ReferenceTemplate

type ReferenceTemplate interface {
	GetFieldsToOmit(fieldsToOmit FieldsToOmit) []*ManifestPathV1
	Exec(params map[string]any) (*unstructured.Unstructured, error)
	GetMetadata() *unstructured.Unstructured
	GetIdentifier() string
	GetPath() string
	GetConfig() TemplateConfig
	GetTemplateTree() *parse.Tree
	GetDescription() string
}

func ParseTemplates added in v0.0.2

func ParseTemplates(ref Reference, fsys fs.FS) ([]ReferenceTemplate, error)

func ParseV1Templates added in v0.1.1

func ParseV1Templates(ref *ReferenceV1, fsys fs.FS) ([]ReferenceTemplate, error)

func ParseV2Templates added in v0.1.1

func ParseV2Templates(ref *ReferenceV2, fsys fs.FS) ([]ReferenceTemplate, error)

type ReferenceTemplateConfigV1 added in v0.1.1

type ReferenceTemplateConfigV1 struct {
	AllowMerge       bool     `json:"ignore-unspecified-fields,omitempty"`
	FieldsToOmitRefs []string `json:"fieldsToOmitRefs,omitempty"`
}

func (ReferenceTemplateConfigV1) GetAllowMerge added in v0.1.1

func (config ReferenceTemplateConfigV1) GetAllowMerge() bool

func (ReferenceTemplateConfigV1) GetFieldsToOmitRefs added in v0.1.1

func (config ReferenceTemplateConfigV1) GetFieldsToOmitRefs() []string

func (ReferenceTemplateConfigV1) GetInlineDiffFuncs added in v0.3.0

func (config ReferenceTemplateConfigV1) GetInlineDiffFuncs() map[string]inlineDiffType

type ReferenceTemplateConfigV2 added in v0.3.0

type ReferenceTemplateConfigV2 struct {
	PerField []*PerFieldConfigV2 `json:"perField,omitempty"`
	ReferenceTemplateConfigV1
}

func (ReferenceTemplateConfigV2) GetInlineDiffFuncs added in v0.3.0

func (config ReferenceTemplateConfigV2) GetInlineDiffFuncs() map[string]inlineDiffType

type ReferenceTemplateV1 added in v0.1.1

type ReferenceTemplateV1 struct {
	*template.Template `json:"-"`
	Path               string                    `json:"path"`
	Description        string                    `json:"description,omitempty"`
	Config             ReferenceTemplateConfigV1 `json:"config,omitempty"`
	// contains filtered or unexported fields
}

func (ReferenceTemplateV1) Exec added in v0.1.1

func (rf ReferenceTemplateV1) Exec(params map[string]any) (*unstructured.Unstructured, error)

func (ReferenceTemplateV1) GetConfig added in v0.1.1

func (rf ReferenceTemplateV1) GetConfig() TemplateConfig

func (ReferenceTemplateV1) GetDescription added in v0.3.0

func (rf ReferenceTemplateV1) GetDescription() string

func (ReferenceTemplateV1) GetFieldsToOmit added in v0.1.1

func (rf ReferenceTemplateV1) GetFieldsToOmit(fieldsToOmit FieldsToOmit) []*ManifestPathV1

func (ReferenceTemplateV1) GetIdentifier added in v0.1.1

func (rf ReferenceTemplateV1) GetIdentifier() string

func (ReferenceTemplateV1) GetMetadata added in v0.1.1

func (rf ReferenceTemplateV1) GetMetadata() *unstructured.Unstructured

func (ReferenceTemplateV1) GetPath added in v0.1.1

func (rf ReferenceTemplateV1) GetPath() string

func (ReferenceTemplateV1) GetTemplateTree added in v0.1.1

func (rf ReferenceTemplateV1) GetTemplateTree() *parse.Tree

func (ReferenceTemplateV1) ValidateFieldsToOmit added in v0.1.1

func (rf ReferenceTemplateV1) ValidateFieldsToOmit(fieldsToOmit FieldsToOmit) error

type ReferenceTemplateV2 added in v0.3.0

type ReferenceTemplateV2 struct {
	Config ReferenceTemplateConfigV2 `json:"config,omitempty"`
	ReferenceTemplateV1
}

func (ReferenceTemplateV2) GetConfig added in v0.3.0

func (rf ReferenceTemplateV2) GetConfig() TemplateConfig

type ReferenceV1 added in v0.1.1

type ReferenceV1 struct {
	Version string `json:"apiVersion,omitempty"`

	Parts                 []PartV1        `json:"parts"`
	TemplateFunctionFiles []string        `json:"templateFunctionFiles,omitempty"`
	FieldsToOmit          *FieldsToOmitV1 `json:"fieldsToOmit,omitempty"`
	// contains filtered or unexported fields
}

func (*ReferenceV1) GetAPIVersion added in v0.1.1

func (r *ReferenceV1) GetAPIVersion() string

func (*ReferenceV1) GetFieldsToOmit added in v0.1.1

func (r *ReferenceV1) GetFieldsToOmit() FieldsToOmit

func (*ReferenceV1) GetTemplateFunctionFiles added in v0.1.1

func (r *ReferenceV1) GetTemplateFunctionFiles() []string

func (*ReferenceV1) GetTemplates added in v0.1.1

func (r *ReferenceV1) GetTemplates() []ReferenceTemplate

func (*ReferenceV1) GetValidationIssues added in v0.1.1

func (r *ReferenceV1) GetValidationIssues(matchedTemplates map[string]int) (map[string]map[string]ValidationIssue, int)

type ReferenceV2 added in v0.1.1

type ReferenceV2 struct {
	Version string `json:"apiVersion,omitempty"`

	Parts                 []*PartV2       `json:"parts"`
	TemplateFunctionFiles []string        `json:"templateFunctionFiles,omitempty"`
	FieldsToOmit          *FieldsToOmitV2 `json:"fieldsToOmit,omitempty"`
	// contains filtered or unexported fields
}

func (*ReferenceV2) GetAPIVersion added in v0.1.1

func (r *ReferenceV2) GetAPIVersion() string

func (*ReferenceV2) GetFieldsToOmit added in v0.1.1

func (r *ReferenceV2) GetFieldsToOmit() FieldsToOmit

func (*ReferenceV2) GetTemplateFunctionFiles added in v0.1.1

func (r *ReferenceV2) GetTemplateFunctionFiles() []string

func (*ReferenceV2) GetTemplates added in v0.1.1

func (r *ReferenceV2) GetTemplates() []ReferenceTemplate

func (*ReferenceV2) GetValidationIssues added in v0.1.1

func (r *ReferenceV2) GetValidationIssues(matchedTemplates map[string]int) (map[string]map[string]ValidationIssue, int)

type RegexInlineDiff added in v0.3.0

type RegexInlineDiff struct{}

func (RegexInlineDiff) Diff added in v0.3.0

func (id RegexInlineDiff) Diff(regex, crValue string) string

func (RegexInlineDiff) Validate added in v0.3.0

func (id RegexInlineDiff) Validate(regex string) error

type Summary

type Summary struct {
	ValidationIssues map[string]map[string]ValidationIssue `json:"ValidationIssuses"`
	NumMissing       int                                   `json:"NumMissing"`
	UnmatchedCRS     []string                              `json:"UnmatchedCRS"`
	NumDiffCRs       int                                   `json:"NumDiffCRs"`
	TotalCRs         int                                   `json:"TotalCRs"`
	MetadataHash     string                                `json:"MetadataHash"`
	PatchedCRs       int                                   `json:"patchedCRs"`
}

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

func (Summary) String

func (s Summary) String() string

type TemplateConfig added in v0.1.1

type TemplateConfig interface {
	GetAllowMerge() bool
	GetFieldsToOmitRefs() []string
	GetInlineDiffFuncs() map[string]inlineDiffType
}

type UnknownMatch

type UnknownMatch struct {
	Resource *unstructured.Unstructured
}

UnknownMatch an error that can be returned by a Correlator 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"`
}

type UserOverride added in v0.1.1

type UserOverride struct {
	Name         string    `json:"name,omitempty"`
	ApiVersion   string    `json:"apiVersion,omitempty"`
	Kind         string    `json:"kind,omitempty"`
	Namespace    string    `json:"namespace,omitempty"`
	ExactMatch   string    `json:"exactMatch,omitempty"`
	Reason       string    `json:"reason"`
	Type         patchType `json:"type"`
	Patch        string    `json:"patch"`
	TemplatePath string    `json:"templatePath"`
}

func CreateMergePatch added in v0.1.1

func CreateMergePatch(temp ReferenceTemplate, obj *InfoObject, reason string) (*UserOverride, error)

func LoadUserOverrides added in v0.1.1

func LoadUserOverrides(path string) ([]*UserOverride, error)

func (UserOverride) Apply added in v0.1.1

func (UserOverride) GetIdentifier added in v0.1.1

func (o UserOverride) GetIdentifier() string

func (UserOverride) GetMetadata added in v0.1.1

func (o UserOverride) GetMetadata() *unstructured.Unstructured

func (UserOverride) GetName added in v0.1.1

func (o UserOverride) GetName() string

type ValidationIssue added in v0.1.1

type ValidationIssue struct {
	Msg        string                `json:"Msg,omitempty"`
	CRs        []string              `json:"CRs,omitempty"`
	CRMetadata map[string]CRMetadata `json:"crMetadata,omitempty"`
}

Jump to

Keyboard shortcuts

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