discovery

package
v0.0.0-...-05ee0c8 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package discovery contains types and methods pertaining to the discovery of aspects of a kubernetes cluster. For example, when new images are used on Pods or new Namespaces are created.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewImageDiscoverer

func NewImageDiscoverer(writer EventWriter, store ImageStore) event.Handler

NewImageDiscoverer returns an event.Handler that handles inbound resource creation and update events and produces discovery events when a Pod is using a container image that has not been persisted to the ImageStore.

func NewNamespaceDiscoverer

func NewNamespaceDiscoverer(writer EventWriter, store NamespaceStore) event.Handler

NewNamespaceDiscoverer returns an event.Handler that handles inbound resource creation and update events and produces discovery events when a namespace is created/updated that has not been persisted to the NamespaceStore.

Types

type BadgerStore

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

The BadgerStore type implements the ImageStore and NamespaceStore interfaces and persists data to a badgerdb instance.

func NewBadgerStore

func NewBadgerStore(path string) (*BadgerStore, error)

NewBadgerStore returns a new instance of the BadgerStore type that will create/open a badger database at the given path. Returns an error if opening or creating the database fails.

func (*BadgerStore) Close

func (bs *BadgerStore) Close() error

Close the database.

func (*BadgerStore) ImageExists

func (bs *BadgerStore) ImageExists(ctx context.Context, image string) (bool, error)

ImageExists returns true if the provided image has already been persisted.

func (*BadgerStore) NamespaceExists

func (bs *BadgerStore) NamespaceExists(ctx context.Context, namespace string) (bool, error)

NamespaceExists returns true if the provided namespace has already been persisted.

func (*BadgerStore) SaveImage

func (bs *BadgerStore) SaveImage(ctx context.Context, image string) error

SaveImage adds a new image to the database.

func (*BadgerStore) SaveNamespace

func (bs *BadgerStore) SaveNamespace(ctx context.Context, namespace string) error

SaveNamespace adds a new namespace to the database.

type Discoverer

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

The Discoverer type is used to check resource data from inbound events and produce discovery events.

func NewDiscoverer

func NewDiscoverer(reader EventReader, handlers []event.Handler) *Discoverer

NewDiscoverer returns a new instance of the Discoverer type that will read inbound events from the provided EventReader implementation. For each inbound event, the provided event.Handler functions will be invoked. These handlers are responsible for checking the resource data and publishing discovery events if necessary.

func (*Discoverer) Discover

func (d *Discoverer) Discover(ctx context.Context) error

Discover information regarding cluster resources from inbound events. This method blocks until an error occurs in a handler or the given context.Context is cancelled.

type EventReader

type EventReader interface {
	Read(ctx context.Context, fn event.Handler) error
}

The EventReader interface describes types that can read events from an arbitrary event stream.

type EventWriter

type EventWriter interface {
	Write(ctx context.Context, evt event.Event) error
}

The EventWriter interface describes types that can write events to an arbitrary event stream.

type ImageStore

type ImageStore interface {
	ImageExists(ctx context.Context, image string) (bool, error)
	SaveImage(ctx context.Context, image string) error
}

The ImageStore interface describes types that persist and query container image names.

type NamespaceStore

type NamespaceStore interface {
	NamespaceExists(ctx context.Context, namespace string) (bool, error)
	SaveNamespace(ctx context.Context, namespace string) error
}

The NamespaceStore interface describes types that persist and query cluster namespace names.

Jump to

Keyboard shortcuts

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