local

package
v0.0.0-...-52e0d5c Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 40 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(stores map[cluster.ID]model.ConfigStore, cancelCh <-chan struct{}, collectionReporter CollectionReporterFn) analysis.Context

NewContext allows tests to use istiodContext without exporting it. returned context is not threadsafe.

Types

type AnalysisResult

type AnalysisResult struct {
	Messages          diag.Messages
	MappedMessages    map[string]diag.Messages
	SkippedAnalyzers  []string
	ExecutedAnalyzers []string
}

AnalysisResult represents the returnable results of an analysis execution

type AnalysisSuppression

type AnalysisSuppression struct {
	// Code is the analysis code to suppress (e.g. "IST0104").
	Code string

	// ResourceName is the name of the resource to suppress the message for. For
	// K8s resources it has the same form as used by istioctl (e.g.
	// "DestinationRule default.istio-system"). Note that globbing wildcards are
	// supported (e.g. "DestinationRule *.istio-system").
	ResourceName string
}

AnalysisSuppression describes a resource and analysis code to be suppressed (e.g. ignored) during analysis. Used when a particular message code is to be ignored for a specific resource.

type CollectionReporterFn

type CollectionReporterFn func(config.GroupVersionKind)

CollectionReporterFn is a hook function called whenever a collection is accessed through the AnalyzingDistributor's context

type IstiodAnalyzer

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

IstiodAnalyzer handles local analysis of k8s event sources, both live and file-based

func NewIstiodAnalyzer

func NewIstiodAnalyzer(analyzer analysis.CombinedAnalyzer, namespace,
	istioNamespace resource.Namespace, cr CollectionReporterFn,
) *IstiodAnalyzer

NewIstiodAnalyzer creates a new IstiodAnalyzer with no sources. Use the Add*Source methods to add sources in ascending precedence order, then execute Analyze to perform the analysis

func NewSourceAnalyzer

func NewSourceAnalyzer(analyzer analysis.CombinedAnalyzer, namespace, istioNamespace resource.Namespace, cr CollectionReporterFn) *IstiodAnalyzer

NewSourceAnalyzer is a drop-in replacement for the galley function, adapting to istiod analyzer.

func (*IstiodAnalyzer) AddDefaultResources

func (sa *IstiodAnalyzer) AddDefaultResources() error

AddDefaultResources adds some basic dummy Istio resources, based on mesh configuration. This is useful for files-only analysis cases where we don't expect the user to be including istio system resources and don't want to generate false positives because they aren't there. Respect mesh config when deciding which default resources should be generated

func (*IstiodAnalyzer) AddFileKubeMeshConfig

func (sa *IstiodAnalyzer) AddFileKubeMeshConfig(file string) error

AddFileKubeMeshConfig gets mesh config from the specified yaml file

func (*IstiodAnalyzer) AddFileKubeMeshNetworks

func (sa *IstiodAnalyzer) AddFileKubeMeshNetworks(file string) error

AddFileKubeMeshNetworks gets a file meshnetworks and add it to the analyzer.

func (*IstiodAnalyzer) AddReaderKubeSource

func (sa *IstiodAnalyzer) AddReaderKubeSource(readers []ReaderSource) error

AddReaderKubeSource adds a source based on the specified k8s yaml files to the current IstiodAnalyzer

func (*IstiodAnalyzer) AddRunningKubeSource

func (sa *IstiodAnalyzer) AddRunningKubeSource(c kubelib.Client)

AddRunningKubeSource adds a source based on a running k8s cluster to the current IstiodAnalyzer Also tries to get mesh config from the running cluster, if it can

func (*IstiodAnalyzer) AddRunningKubeSourceWithRevision

func (sa *IstiodAnalyzer) AddRunningKubeSourceWithRevision(c kubelib.Client, revision string, remote bool)

func (*IstiodAnalyzer) AddSource

func (sa *IstiodAnalyzer) AddSource(src model.ConfigStoreController)

AddSource adds a source based on user supplied configstore to the current IstiodAnalyzer Assumes that the source has same or subset of resource types that this analyzer is configured with. This can be used by external users who import the analyzer as a module within their own controllers.

func (*IstiodAnalyzer) AddSourceForCluster

func (sa *IstiodAnalyzer) AddSourceForCluster(src model.ConfigStoreController, clusterName cluster.ID)

AddSourceForCluster adds a source based on user supplied configstore to the current IstiodAnalyzer with cluster specified. It functions like the same as AddSource, but it adds the source to the specified cluster.

func (*IstiodAnalyzer) AddTestReaderKubeSource

func (sa *IstiodAnalyzer) AddTestReaderKubeSource(readers []ReaderSource) error

AddTestReaderKubeSource adds a yaml source to the analyzer, which will analyze runtime resources like pods and namespaces for use in tests.

func (*IstiodAnalyzer) Analyze

func (sa *IstiodAnalyzer) Analyze(cancel <-chan struct{}) (AnalysisResult, error)

Analyze loads the sources and executes the analysis

func (*IstiodAnalyzer) GetFiltersByGVK

func (sa *IstiodAnalyzer) GetFiltersByGVK() map[config.GroupVersionKind]kubetypes.Filter

func (*IstiodAnalyzer) Init

func (sa *IstiodAnalyzer) Init(cancel <-chan struct{}) error

func (*IstiodAnalyzer) ReAnalyze

func (sa *IstiodAnalyzer) ReAnalyze(cancel <-chan struct{}) (AnalysisResult, error)

ReAnalyze loads the sources and executes the analysis, assuming init is already called

func (*IstiodAnalyzer) ReAnalyzeSubset

func (sa *IstiodAnalyzer) ReAnalyzeSubset(kinds sets.Set[config.GroupVersionKind], cancel <-chan struct{}) (AnalysisResult, error)

func (*IstiodAnalyzer) RegisterEventHandler

func (sa *IstiodAnalyzer) RegisterEventHandler(kind config.GroupVersionKind, handler model.EventHandler)

func (*IstiodAnalyzer) Schemas

func (sa *IstiodAnalyzer) Schemas() collection.Schemas

func (*IstiodAnalyzer) SetSuppressions

func (sa *IstiodAnalyzer) SetSuppressions(suppressions []AnalysisSuppression)

SetSuppressions will set the list of suppressions for the analyzer. Any resource that matches the provided suppression will not be included in the final message output.

type ReaderSource

type ReaderSource struct {
	// Name is the name of the source (commonly the path to a file, but can be "-" for sources read from stdin or "" if completely synthetic).
	Name string
	// Reader is the reader instance to use.
	Reader io.Reader
}

ReaderSource is a tuple of a io.Reader and filepath.

Jump to

Keyboard shortcuts

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