Documentation
¶
Index ¶
- Constants
- Variables
- func FuncMap() template.FuncMap
- func NewCmd(f kcmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command
- type Component
- type ComponentType
- type CorrelationSettings
- type Correlator
- type DiffSum
- type ExactMatchCorrelator
- type FieldCorrelator
- type FieldsToOmit
- type GroupCorrelator
- type HTTPFS
- type HTTPFile
- type HTTPFileInfo
- type InfoObject
- type ManifestPath
- type ManualCorrelation
- type MergeError
- type MetricsCorrelatorDecorator
- type MultiCorrelator
- type MultipleMatches
- type Options
- type Output
- type Part
- type Reference
- type ReferenceTemplate
- type ReferenceTemplateConfig
- type Summary
- type UnknownMatch
- type UserConfig
Constants ¶
const ( Json string = "json" Yaml string = "yaml" )
const (
DiffSeparator = "**********************************\n"
)
Variables ¶
var OutputFormats = []string{Json, Yaml}
Functions ¶
func 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 []*ReferenceTemplate `json:"requiredTemplates,omitempty"`
OptionalTemplates []*ReferenceTemplate `json:"optionalTemplates,omitempty"`
}
type ComponentType ¶
type ComponentType string
const ( Required ComponentType = "Required" Optional ComponentType = "Optional" )
type CorrelationSettings ¶
type CorrelationSettings struct {
ManualCorrelation ManualCorrelation `json:"manualCorrelation"`
}
type Correlator ¶
type Correlator interface {
Match(*unstructured.Unstructured) (*ReferenceTemplate, 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 ExactMatchCorrelator ¶
type ExactMatchCorrelator 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(crToTemplate map[string]string, templates []*ReferenceTemplate) (*ExactMatchCorrelator, error)
func (ExactMatchCorrelator) Match ¶
func (c ExactMatchCorrelator) Match(object *unstructured.Unstructured) (*ReferenceTemplate, error)
type FieldCorrelator ¶
type FieldCorrelator struct {
Fields [][]string
// contains filtered or unexported fields
}
func (*FieldCorrelator) ClaimTemplates ¶
func (f *FieldCorrelator) ClaimTemplates(templates []*ReferenceTemplate) []*ReferenceTemplate
func (FieldCorrelator) Match ¶
func (f FieldCorrelator) Match(object *unstructured.Unstructured) (*ReferenceTemplate, error)
func (*FieldCorrelator) ValidateTemplates ¶
func (f *FieldCorrelator) ValidateTemplates() error
type FieldsToOmit ¶
type FieldsToOmit struct {
DefaultOmitRef string `json:"defaultOmitRef,omitempty"`
Items map[string][]*ManifestPath `json:"items,omitempty"`
}
type GroupCorrelator ¶
type GroupCorrelator 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(fieldGroups [][][]string, templates []*ReferenceTemplate) (*GroupCorrelator, 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) Match ¶
func (c *GroupCorrelator) Match(object *unstructured.Unstructured) (*ReferenceTemplate, 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
type HTTPFile ¶
type HTTPFile struct {
// contains filtered or unexported fields
}
HTTPFile represents a file obtained from an HTTP response body.
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
type InfoObject ¶
type InfoObject struct {
FieldsToOmit []*ManifestPath
// 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 ManifestPath ¶
type ManifestPath struct {
PathToKey string `json:"pathToKey"`
IsPrefix bool `json:"isPrefix,omitempty"`
// contains filtered or unexported fields
}
func (*ManifestPath) Process ¶
func (p *ManifestPath) Process() error
type ManualCorrelation ¶
type MergeError ¶
type MergeError struct {
// contains filtered or unexported fields
}
func (MergeError) Error ¶
func (e MergeError) Error() string
type MetricsCorrelatorDecorator ¶
type MetricsCorrelatorDecorator struct {
UnMatchedCRs []*unstructured.Unstructured
MatchedTemplatesNames map[string]bool
// contains filtered or unexported fields
}
MetricsCorrelatorDecorator Matches templates by using an existing correlator and gathers summary info related the correlation.
func NewMetricsCorrelatorDecorator ¶
func NewMetricsCorrelatorDecorator(correlator Correlator, parts []Part, errsToIgnore []error) *MetricsCorrelatorDecorator
func (*MetricsCorrelatorDecorator) Match ¶
func (c *MetricsCorrelatorDecorator) Match(object *unstructured.Unstructured) (*ReferenceTemplate, error)
type MultiCorrelator ¶
type MultiCorrelator 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(correlators []Correlator) *MultiCorrelator
func (MultiCorrelator) Match ¶
func (c MultiCorrelator) Match(object *unstructured.Unstructured) (*ReferenceTemplate, error)
type MultipleMatches ¶
type MultipleMatches struct {
Resource *unstructured.Unstructured
Matches []*ReferenceTemplate
}
MultipleMatches an error that can be returned by a Correlator 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
type Reference ¶
type Reference struct {
Parts []Part `json:"parts"`
TemplateFunctionFiles []string `json:"templateFunctionFiles,omitempty"`
FieldsToOmit FieldsToOmit `json:"fieldsToOmit,omitempty"`
}
type ReferenceTemplate ¶
type ReferenceTemplate struct {
*template.Template
Path string `json:"path"`
Config ReferenceTemplateConfig `json:"config,omitempty"`
// contains filtered or unexported fields
}
func (ReferenceTemplate) Exec ¶
func (rf ReferenceTemplate) Exec(params map[string]any) (*unstructured.Unstructured, error)
func (ReferenceTemplate) FieldsToOmit ¶
func (rf ReferenceTemplate) FieldsToOmit(fieldsToOmit FieldsToOmit) []*ManifestPath
func (ReferenceTemplate) Name ¶
func (rf ReferenceTemplate) Name() string
func (ReferenceTemplate) ValidateFieldsToOmit ¶
func (rf ReferenceTemplate) ValidateFieldsToOmit(fieldsToOmit FieldsToOmit) error
type ReferenceTemplateConfig ¶
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"`
TotalCRs int `json:"TotalCRs"`
}
Summary Contains all info included in the Summary output of the compare command
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"`
}