Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Analyzer ¶
type Analyzer interface { Analyze(obj *status.Object) status.ObjectStatus // Supports should return true if the particular analyzer supports // the given resource. // // It's used when searching the appropriate analyzer in the register. Supports(obj *status.Object) bool }
Analyzer calculates status for the object.
type AnalyzerInit ¶
AnalyzerInit is a function that initializes an Analyzer and can optionally pass an Evaluator reference to it.
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator is the entry structure for the status evaluation cycle.
It peformes the following steps:
- Loading fresh data for the object (though the Loader struct).
- Finding an appropriate Analyzer for the object.
- Evaluating the Analyzer on the object.
func NewEvaluator ¶
func NewEvaluator(ctx context.Context, analyzerInits []AnalyzerInit, config RESTClientGetter) (*Evaluator, error)
NewEvaluator creates a new Evaluator instance.
func (*Evaluator) Eval ¶
func (e *Evaluator) Eval(obj *status.Object) status.ObjectStatus
Evaluates the status of the object. It gets the most recent version of the object and runs the appropriate analyzer on it.
func (*Evaluator) EvalQuery ¶
EvalQuery loads the objects specified by the query and runs the analyzer. If the analyzer is not provided, it tries to find the appropriate one in the register.
type GroupKindMatcher ¶
type GroupKindMatcher struct { // IncludeAll specifies whether all kinds should be included. // If true, the IncludedKinds are ignored. IncludeAll bool // IncludedKinds specifies the kinds to include. It's mutually exclusive // with IncludeAll. IncludedKinds []schema.GroupKind // ExcludedKinds specifies the kinds to exclude. It's only used with // IncludeAll. ExcludedKinds []schema.GroupKind }
GroupKindMatcher allows specifying a set of kinds to match.
func NewGroupKindMatcherSingle ¶
func NewGroupKindMatcherSingle(kind schema.GroupKind) GroupKindMatcher
NewGroupKindMatcherSingle returns a new GroupKindMatcher that matches only a single kind.
func (GroupKindMatcher) Equal ¶
func (m GroupKindMatcher) Equal(other GroupKindMatcher) bool
func (GroupKindMatcher) Merge ¶
func (m GroupKindMatcher) Merge(other GroupKindMatcher) GroupKindMatcher
Merge returns a new GroupKindMatcher that matches the union of the kinds matched by the receiver and the other matcher.
type LabelQuerySpec ¶
type LabelQuerySpec struct { Object *status.Object GK GroupKindMatcher Selector labels.Selector }
LabelQuerySpec is a query that returns objects based on the labels selector. The namespace is taken from the Object.
func NewSelectorLabelEqualityQuerySpec ¶
func NewSelectorLabelEqualityQuerySpec(obj *status.Object, gk schema.GroupKind) LabelQuerySpec
func NewSelectorLabelQuerySpec ¶
func NewSelectorLabelQuerySpec(obj *status.Object, gk schema.GroupKind) LabelQuerySpec
func (LabelQuerySpec) GroupKindMatcher ¶
func (qs LabelQuerySpec) GroupKindMatcher() GroupKindMatcher
func (LabelQuerySpec) Namespace ¶
func (qs LabelQuerySpec) Namespace() string
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is responsible for loading and caching the objects from the cluster. It also allows finding objects based on their ownership relations.
func NewLoader ¶
func NewLoader(config RESTClientGetter) (*Loader, error)
func (*Loader) Filter ¶
func (l *Loader) Filter(ns string, matcher GroupKindMatcher) []*status.Object
Filter returns the objects from the cache that match the matcher. It expects the objects to be in the cache. This methods is intended to run during evaluation of the Load method in the following order:
- The Load method runs preloadQuery to fill in the cache.
- The Load method runs Eval on the query spec to get the objects.
- The Eval method runs Filter to get the objects from the cache.
We need to run the preloadQuery before the Eval method to support searching for objects based on the ownership relations.
type OwnerQuerySpec ¶
type OwnerQuerySpec struct { Object *status.Object GK GroupKindMatcher // NamespaceOverride specifies the namespace of the child object. // If nil, the namespace of the Object is used. NamespaceOverride *string }
OwnerQuerySpec is a query that returns objects owned by the specified object.
func (OwnerQuerySpec) GroupKindMatcher ¶
func (qs OwnerQuerySpec) GroupKindMatcher() GroupKindMatcher
func (OwnerQuerySpec) Namespace ¶
func (qs OwnerQuerySpec) Namespace() string
type PodLogQuerySpec ¶
PodLogQuerySpec is a query that returns logs of the specified pod.
func (PodLogQuerySpec) GroupKindMatcher ¶
func (qs PodLogQuerySpec) GroupKindMatcher() GroupKindMatcher
func (PodLogQuerySpec) Namespace ¶
func (qs PodLogQuerySpec) Namespace() string
type QuerySpec ¶
type QuerySpec interface { // GroupKindMatcher specifies the kinds of objects to load. GroupKindMatcher() GroupKindMatcher // Namespace specifies the namespace of the objects to load. // Together with the GroupKindMatcher, it's used to preload the objects // into the Loader's cache. Namespace() string // Eval evaluates the query and returns the objects. // If applicable, the loader is already preloaded with the objects based // on the GroupKindMatcher and Namespace. It's still the repsonsibility // of the Eval method to do the final filtering. Eval(l *Loader) []*status.Object }
QuerySpec is a specification of a query for objects.
It's a generic interface Loader understands to load objects. The methods are used for preloading the objects before the actual evaluation.
type RESTClientGetter ¶
type RESTClientGetter interface { ToRESTConfig() (*rest.Config, error) ToDiscoveryClient() (discoveryclient.CachedDiscoveryInterface, error) ToRESTMapper() (meta.RESTMapper, error) }
RESTClientGetter is an interface with a subset of k8s.io/cli-runtime/pkg/genericclioptions.RESTClientGetter, We reduce it only to the methods we need.
type RefQuerySpec ¶
type RefQuerySpec struct { Object *status.Object RefObject corev1.ObjectReference }
RefQuerySpec is a query that returns objects referenced by the specified object. It assumes the reference to be in the same namespace.
func (RefQuerySpec) GroupKindMatcher ¶
func (qs RefQuerySpec) GroupKindMatcher() GroupKindMatcher
func (RefQuerySpec) Namespace ¶
func (qs RefQuerySpec) Namespace() string
type StatusPoller ¶
type StatusPoller struct {
// contains filtered or unexported fields
}
StatusPoller polls the status of a set of objects at a regular interval.
func NewStatusPoller ¶
func (*StatusPoller) Start ¶
func (s *StatusPoller) Start(ctx context.Context) <-chan StatusUpdate
Start starts the poller and returns a channel that will receive status updates. The poller will run until the context is canceled. The channel will be closed when the context is canceled.
type StatusUpdate ¶
type StatusUpdate struct { Statuses []status.ObjectStatus Error error }