container

package
v0.0.0-...-25f5b1c Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backup

type Backup struct {
	// Base
	BaseCollection
}

A collection of k8s Backup resources.

func (*Backup) AddWatch

func (r *Backup) AddWatch(dsController controller.Controller) error

func (*Backup) Create

func (r *Backup) Create(e event.CreateEvent) bool

func (*Backup) Delete

func (r *Backup) Delete(e event.DeleteEvent) bool

func (*Backup) Generic

func (r *Backup) Generic(e event.GenericEvent) bool

func (*Backup) GetDiscovered

func (r *Backup) GetDiscovered() ([]model.Model, error)

func (*Backup) GetStored

func (r *Backup) GetStored() ([]model.Model, error)

func (*Backup) Reconcile

func (r *Backup) Reconcile() error

func (*Backup) Update

func (r *Backup) Update(e event.UpdateEvent) bool

type BaseCollection

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

Base collection. Provides base fields and methods for collections.

func (*BaseCollection) Bind

func (r *BaseCollection) Bind(ds *DataSource)

Bind to a DataSource.

func (*BaseCollection) GetDs

func (r *BaseCollection) GetDs() *DataSource

Get the associated DataSource.

func (*BaseCollection) IsReady

func (r *BaseCollection) IsReady() bool

Get whether the collection has reconciled.

func (*BaseCollection) Reset

func (r *BaseCollection) Reset()

Reset `hasReconciled` and association with a DataSource.

type Collection

type Collection interface {
	// Associate with a DataSource.
	// Mainly to support two phase construction.
	Bind(ds *DataSource)
	// Get the associated DataSource.
	GetDs() *DataSource
	// Add k8s watches.
	// Each watch MUST include a predicate that performs the
	// appropriate changes in the DB instead of creating
	// reconcile events.
	AddWatch(c controller.Controller) error
	// Reconcile the cluster and the DB.
	// Discover resources on the cluster modify the DB as needed.
	// Intended to be performed once when the collection is initialized.
	// The term is borrowed from k8s and similar but different.
	Reconcile() error
	// Get whether the collection is ready to be used.
	// Mainly, that it has been fully initialized (reconciled) and
	// protects against partial data sets.
	IsReady() bool
	// Reset the collection to a like-new state.
	// A reset collection is no longer ready and needs to be reconciled again.
	Reset()
	// Get a list of resources discovered on the cluster.
	// Intended to support `Reconcile()`.
	GetDiscovered() ([]model.Model, error)
	// Get a list of resources stored in the DB.
	// Intended to support `Reconcile()`
	GetStored() ([]model.Model, error)
}

Collection of resources. Each collection loosely corresponds to a k8s resource and to a resource in the REST API. It is responsible for setting up watches; performing discovery and managing the inventory in the DB.

type Collections

type Collections []Collection

type Container

type Container struct {
	// A k8s client for the host cluster.
	Client client.Client
	// A database connection.
	Db *sql.DB
	// contains filtered or unexported fields
}

Container of DataSources. Each DataSource corresponds to a MigCluster. The container is responsible for the lifecycle of DataSources based on add,update,delete of MigCluster.

func NewContainer

func NewContainer(cnt client.Client, db *sql.DB) *Container

Construct a new container.

func (*Container) Add

func (r *Container) Add(cluster *migapi.MigCluster, collections ...Collection) error

Add a cluster to the container. Build/update a DataSource for the cluster as needed.

func (*Container) Delete

func (r *Container) Delete(cluster types.NamespacedName)

Delete the DataSource for a deleted MigCluster.

func (*Container) GetDs

func (r *Container) GetDs(cluster *model.Cluster) (*DataSource, bool)

Get the DataSource for a cluster.

func (*Container) HasCluster

func (r *Container) HasCluster(cluster *model.Cluster) (bool, error)

Determine of a MigCluster actually exists.

func (*Container) Prune

func (r *Container) Prune() error

Prune (delete) clusters in the DB that no longer exist. Intended to call called once on container initialization.

type DataSource

type DataSource struct {
	// The associated (owner) container.
	Container *Container
	// Collections.
	Collections Collections
	// The REST configuration for the cluster.
	RestCfg *rest.Config
	// The k8s client for the cluster.
	Client client.Client
	// The corresponding cluster in the DB.
	Cluster model.Cluster
	// contains filtered or unexported fields
}

A DataSource corresponds to a MigCluster and is responsible for maintaining a k8s:

  • Manager/controller
  • REST configuration
  • Client

Each contains a set of `Collection`.

func (*DataSource) Create

func (r *DataSource) Create(m model.Model)

Enqueue create model event. Used by watch predicates. Swallow panic: send on closed channel.

func (*DataSource) Delete

func (r *DataSource) Delete(m model.Model)

Enqueue delete model event. Used by watch predicates. Swallow panic: send on closed channel.

func (*DataSource) HasDiscovered

func (r *DataSource) HasDiscovered(m model.Model)

The specified model has been discovered. The `versionThreshold` will be updated as needed.

func (*DataSource) IsReady

func (r *DataSource) IsReady() bool

Determine if the DataSource is `ready`. The DataSource is `ready` when all of the collections are `ready`.

func (*DataSource) Reconcile

func (r *DataSource) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)

The k8s reconcile loop. Implements the k8s Reconciler interface. The DataSource is the reconciler for the container k8s manager/controller but is should never be called. The design is for watches added by each collection reference a predicate that handles the change rather than queuing a reconcile event.

func (*DataSource) Start

func (r *DataSource) Start(cluster *migapi.MigCluster) error

Start the DataSource.

  • Create the cluster in the DB.
  • Create a k8s client.
  • Reconcile each collection.

func (*DataSource) Stop

func (r *DataSource) Stop(purge bool)

Stop the DataSource. Stop the associated k8s manager/controller and delete all of the associated data in the DB. The data should be deleted when the DataSource is not being restarted.

func (*DataSource) Update

func (r *DataSource) Update(m model.Model)

Enqueue update model event. Used by watch predicates. Swallow panic: send on closed channel.

type DirectImageMigration

type DirectImageMigration struct {
	// Base
	BaseCollection
}

A collection of k8s DirectImageMigration resources.

func (*DirectImageMigration) AddWatch

func (r *DirectImageMigration) AddWatch(dsController controller.Controller) error

func (*DirectImageMigration) Create

func (*DirectImageMigration) Delete

func (*DirectImageMigration) Generic

func (*DirectImageMigration) GetDiscovered

func (r *DirectImageMigration) GetDiscovered() ([]model.Model, error)

func (*DirectImageMigration) GetStored

func (r *DirectImageMigration) GetStored() ([]model.Model, error)

func (*DirectImageMigration) Reconcile

func (r *DirectImageMigration) Reconcile() error

func (*DirectImageMigration) Update

type DirectImageStreamMigration

type DirectImageStreamMigration struct {
	// Base
	BaseCollection
}

A collection of k8s DirectImageStreamMigration resources.

func (*DirectImageStreamMigration) AddWatch

func (r *DirectImageStreamMigration) AddWatch(dsController controller.Controller) error

func (*DirectImageStreamMigration) Create

func (*DirectImageStreamMigration) Delete

func (*DirectImageStreamMigration) Generic

func (*DirectImageStreamMigration) GetDiscovered

func (r *DirectImageStreamMigration) GetDiscovered() ([]model.Model, error)

func (*DirectImageStreamMigration) GetStored

func (r *DirectImageStreamMigration) GetStored() ([]model.Model, error)

func (*DirectImageStreamMigration) Reconcile

func (r *DirectImageStreamMigration) Reconcile() error

func (*DirectImageStreamMigration) Update

type DirectVolumeMigration

type DirectVolumeMigration struct {
	// Base
	BaseCollection
}

A collection of k8s DirectVolumeMigration resources.

func (*DirectVolumeMigration) AddWatch

func (r *DirectVolumeMigration) AddWatch(dsController controller.Controller) error

func (*DirectVolumeMigration) Create

func (*DirectVolumeMigration) Delete

func (*DirectVolumeMigration) Generic

func (*DirectVolumeMigration) GetDiscovered

func (r *DirectVolumeMigration) GetDiscovered() ([]model.Model, error)

func (*DirectVolumeMigration) GetStored

func (r *DirectVolumeMigration) GetStored() ([]model.Model, error)

func (*DirectVolumeMigration) Reconcile

func (r *DirectVolumeMigration) Reconcile() error

func (*DirectVolumeMigration) Update

type DirectVolumeMigrationProgress

type DirectVolumeMigrationProgress struct {
	// Base
	BaseCollection
}

A collection of k8s DirectVolumeMigrationProgress resources.

func (*DirectVolumeMigrationProgress) AddWatch

func (r *DirectVolumeMigrationProgress) AddWatch(dsController controller.Controller) error

func (*DirectVolumeMigrationProgress) Create

func (*DirectVolumeMigrationProgress) Delete

func (*DirectVolumeMigrationProgress) Generic

func (*DirectVolumeMigrationProgress) GetDiscovered

func (r *DirectVolumeMigrationProgress) GetDiscovered() ([]model.Model, error)

func (*DirectVolumeMigrationProgress) GetStored

func (r *DirectVolumeMigrationProgress) GetStored() ([]model.Model, error)

func (*DirectVolumeMigrationProgress) Reconcile

func (r *DirectVolumeMigrationProgress) Reconcile() error

func (*DirectVolumeMigrationProgress) Update

type Disposition

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

Disposition. Used for collection reconcile and describes whether a resource has been `discovered` (exists on the cluster); Is `stored` in the inventory; or both. A `nil` pointer means that the resource does not exist.

type DsKey

type DsKey types.NamespacedName

DataSource Key

type Event

type Event struct {
	// Base
	BaseCollection
}

A collection of k8s Event resources.

func (*Event) AddWatch

func (r *Event) AddWatch(dsController controller.Controller) error

func (*Event) Create

func (r *Event) Create(e event.CreateEvent) bool

func (*Event) Delete

func (r *Event) Delete(e event.DeleteEvent) bool

func (*Event) Generic

func (r *Event) Generic(e event.GenericEvent) bool

func (*Event) GetDiscovered

func (r *Event) GetDiscovered() ([]model.Model, error)

func (*Event) GetStored

func (r *Event) GetStored() ([]model.Model, error)

func (*Event) Reconcile

func (r *Event) Reconcile() error

func (*Event) Update

func (r *Event) Update(e event.UpdateEvent) bool

type Hook

type Hook struct {
	// Base
	BaseCollection
}

A collection of k8s Hook resources.

func (*Hook) AddWatch

func (r *Hook) AddWatch(dsController controller.Controller) error

func (*Hook) Create

func (r *Hook) Create(e event.CreateEvent) bool

func (*Hook) Delete

func (r *Hook) Delete(e event.DeleteEvent) bool

func (*Hook) Generic

func (r *Hook) Generic(e event.GenericEvent) bool

func (*Hook) GetDiscovered

func (r *Hook) GetDiscovered() ([]model.Model, error)

func (*Hook) GetStored

func (r *Hook) GetStored() ([]model.Model, error)

func (*Hook) Reconcile

func (r *Hook) Reconcile() error

func (*Hook) Update

func (r *Hook) Update(e event.UpdateEvent) bool

type Job

type Job struct {
	// Base
	BaseCollection
}

A collection of k8s Job resources.

func (*Job) AddWatch

func (r *Job) AddWatch(dsController controller.Controller) error

func (*Job) Create

func (r *Job) Create(e event.CreateEvent) bool

func (*Job) Delete

func (r *Job) Delete(e event.DeleteEvent) bool

func (*Job) Generic

func (r *Job) Generic(e event.GenericEvent) bool

func (*Job) GetDiscovered

func (r *Job) GetDiscovered() ([]model.Model, error)

func (*Job) GetStored

func (r *Job) GetStored() ([]model.Model, error)

func (*Job) Reconcile

func (r *Job) Reconcile() error

func (*Job) Update

func (r *Job) Update(e event.UpdateEvent) bool

type Migration

type Migration struct {
	// Base
	BaseCollection
}

A collection of k8s Migration resources.

func (*Migration) AddWatch

func (r *Migration) AddWatch(dsController controller.Controller) error

func (*Migration) Create

func (r *Migration) Create(e event.CreateEvent) bool

func (*Migration) Delete

func (r *Migration) Delete(e event.DeleteEvent) bool

func (*Migration) Generic

func (r *Migration) Generic(e event.GenericEvent) bool

func (*Migration) GetDiscovered

func (r *Migration) GetDiscovered() ([]model.Model, error)

func (*Migration) GetStored

func (r *Migration) GetStored() ([]model.Model, error)

func (*Migration) Reconcile

func (r *Migration) Reconcile() error

func (*Migration) Update

func (r *Migration) Update(e event.UpdateEvent) bool

type ModelEvent

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

Model event. Used with `eventChannel`.

func (*ModelEvent) Apply

func (r *ModelEvent) Apply(db *sql.DB, versionThreshold uint64) (err error)

Apply the change to the DB.

func (ModelEvent) Create

func (r ModelEvent) Create(m model.Model) ModelEvent

Set the event model and action.

func (ModelEvent) Delete

func (r ModelEvent) Delete(m model.Model) ModelEvent

Set the event model and action.

func (ModelEvent) Update

func (r ModelEvent) Update(m model.Model) ModelEvent

Set the event model and action.

type Namespace

type Namespace struct {
	// Base
	BaseCollection
}

A collection of k8s Namespace resources.

func (*Namespace) AddWatch

func (r *Namespace) AddWatch(dsController controller.Controller) error

func (*Namespace) Create

func (r *Namespace) Create(e event.CreateEvent) bool

func (*Namespace) Delete

func (r *Namespace) Delete(e event.DeleteEvent) bool

func (*Namespace) Generic

func (r *Namespace) Generic(e event.GenericEvent) bool

func (*Namespace) GetDiscovered

func (r *Namespace) GetDiscovered() ([]model.Model, error)

func (*Namespace) GetStored

func (r *Namespace) GetStored() ([]model.Model, error)

func (*Namespace) Reconcile

func (r *Namespace) Reconcile() error

func (*Namespace) Update

func (r *Namespace) Update(e event.UpdateEvent) bool

type PV

type PV struct {
	// Base
	BaseCollection
}

A collection of k8s PV resources.

func (*PV) AddWatch

func (r *PV) AddWatch(dsController controller.Controller) error

func (*PV) Create

func (r *PV) Create(e event.CreateEvent) bool

func (*PV) Delete

func (r *PV) Delete(e event.DeleteEvent) bool

func (*PV) Generic

func (r *PV) Generic(e event.GenericEvent) bool

func (*PV) GetDiscovered

func (r *PV) GetDiscovered() ([]model.Model, error)

func (*PV) GetStored

func (r *PV) GetStored() ([]model.Model, error)

func (*PV) Reconcile

func (r *PV) Reconcile() error

func (*PV) Update

func (r *PV) Update(e event.UpdateEvent) bool

type PVC

type PVC struct {
	// Base
	BaseCollection
}

A collection of k8s PVC resources.

func (*PVC) AddWatch

func (r *PVC) AddWatch(dsController controller.Controller) error

func (*PVC) Create

func (r *PVC) Create(e event.CreateEvent) bool

func (*PVC) Delete

func (r *PVC) Delete(e event.DeleteEvent) bool

func (*PVC) Generic

func (r *PVC) Generic(e event.GenericEvent) bool

func (*PVC) GetDiscovered

func (r *PVC) GetDiscovered() ([]model.Model, error)

func (*PVC) GetStored

func (r *PVC) GetStored() ([]model.Model, error)

func (*PVC) Reconcile

func (r *PVC) Reconcile() error

func (*PVC) Update

func (r *PVC) Update(e event.UpdateEvent) bool

type Plan

type Plan struct {
	// Base
	BaseCollection
}

A collection of k8s Plan resources.

func (*Plan) AddWatch

func (r *Plan) AddWatch(dsController controller.Controller) error

func (*Plan) Create

func (r *Plan) Create(e event.CreateEvent) bool

func (*Plan) Delete

func (r *Plan) Delete(e event.DeleteEvent) bool

func (*Plan) Generic

func (r *Plan) Generic(e event.GenericEvent) bool

func (*Plan) GetDiscovered

func (r *Plan) GetDiscovered() ([]model.Model, error)

func (*Plan) GetStored

func (r *Plan) GetStored() ([]model.Model, error)

func (*Plan) Reconcile

func (r *Plan) Reconcile() error

func (*Plan) Update

func (r *Plan) Update(e event.UpdateEvent) bool

type Pod

type Pod struct {
	// Base
	BaseCollection
}

A collection of k8s Pod resources.

func (*Pod) AddWatch

func (r *Pod) AddWatch(dsController controller.Controller) error

func (*Pod) Create

func (r *Pod) Create(e event.CreateEvent) bool

func (*Pod) Delete

func (r *Pod) Delete(e event.DeleteEvent) bool

func (*Pod) Generic

func (r *Pod) Generic(e event.GenericEvent) bool

func (*Pod) GetDiscovered

func (r *Pod) GetDiscovered() ([]model.Model, error)

func (*Pod) GetStored

func (r *Pod) GetStored() ([]model.Model, error)

func (*Pod) Reconcile

func (r *Pod) Reconcile() error

func (*Pod) Update

func (r *Pod) Update(e event.UpdateEvent) bool

type PodVolumeBackup

type PodVolumeBackup struct {
	// Base
	BaseCollection
}

A collection of k8s PodVolumeBackup resources.

func (*PodVolumeBackup) AddWatch

func (r *PodVolumeBackup) AddWatch(dsController controller.Controller) error

func (*PodVolumeBackup) Create

func (r *PodVolumeBackup) Create(e event.CreateEvent) bool

func (*PodVolumeBackup) Delete

func (r *PodVolumeBackup) Delete(e event.DeleteEvent) bool

func (*PodVolumeBackup) Generic

func (r *PodVolumeBackup) Generic(e event.GenericEvent) bool

func (*PodVolumeBackup) GetDiscovered

func (r *PodVolumeBackup) GetDiscovered() ([]model.Model, error)

func (*PodVolumeBackup) GetStored

func (r *PodVolumeBackup) GetStored() ([]model.Model, error)

func (*PodVolumeBackup) Reconcile

func (r *PodVolumeBackup) Reconcile() error

func (*PodVolumeBackup) Update

func (r *PodVolumeBackup) Update(e event.UpdateEvent) bool

type PodVolumeRestore

type PodVolumeRestore struct {
	// Base
	BaseCollection
}

A collection of k8s PodVolumeRestore resources.

func (*PodVolumeRestore) AddWatch

func (r *PodVolumeRestore) AddWatch(dsController controller.Controller) error

func (*PodVolumeRestore) Create

func (r *PodVolumeRestore) Create(e event.CreateEvent) bool

func (*PodVolumeRestore) Delete

func (r *PodVolumeRestore) Delete(e event.DeleteEvent) bool

func (*PodVolumeRestore) Generic

func (r *PodVolumeRestore) Generic(e event.GenericEvent) bool

func (*PodVolumeRestore) GetDiscovered

func (r *PodVolumeRestore) GetDiscovered() ([]model.Model, error)

func (*PodVolumeRestore) GetStored

func (r *PodVolumeRestore) GetStored() ([]model.Model, error)

func (*PodVolumeRestore) Reconcile

func (r *PodVolumeRestore) Reconcile() error

func (*PodVolumeRestore) Update

func (r *PodVolumeRestore) Update(e event.UpdateEvent) bool

type Restore

type Restore struct {
	// Base
	BaseCollection
}

A collection of k8s Restore resources.

func (*Restore) AddWatch

func (r *Restore) AddWatch(dsController controller.Controller) error

func (*Restore) Create

func (r *Restore) Create(e event.CreateEvent) bool

func (*Restore) Delete

func (r *Restore) Delete(e event.DeleteEvent) bool

func (*Restore) Generic

func (r *Restore) Generic(e event.GenericEvent) bool

func (*Restore) GetDiscovered

func (r *Restore) GetDiscovered() ([]model.Model, error)

func (*Restore) GetStored

func (r *Restore) GetStored() ([]model.Model, error)

func (*Restore) Reconcile

func (r *Restore) Reconcile() error

func (*Restore) Update

func (r *Restore) Update(e event.UpdateEvent) bool

type Route

type Route struct {
	// Base
	BaseCollection
}

A collection of k8s Route resources.

func (*Route) AddWatch

func (r *Route) AddWatch(dsController controller.Controller) error

func (*Route) Create

func (r *Route) Create(e event.CreateEvent) bool

func (*Route) Delete

func (r *Route) Delete(e event.DeleteEvent) bool

func (*Route) Generic

func (r *Route) Generic(e event.GenericEvent) bool

func (*Route) GetDiscovered

func (r *Route) GetDiscovered() ([]model.Model, error)

func (*Route) GetStored

func (r *Route) GetStored() ([]model.Model, error)

func (*Route) Reconcile

func (r *Route) Reconcile() error

func (*Route) Update

func (r *Route) Update(e event.UpdateEvent) bool

type Service

type Service struct {
	// Base
	BaseCollection
}

A collection of k8s Service resources.

func (*Service) AddWatch

func (r *Service) AddWatch(dsController controller.Controller) error

func (*Service) Create

func (r *Service) Create(e event.CreateEvent) bool

func (*Service) Delete

func (r *Service) Delete(e event.DeleteEvent) bool

func (*Service) Generic

func (r *Service) Generic(e event.GenericEvent) bool

func (*Service) GetDiscovered

func (r *Service) GetDiscovered() ([]model.Model, error)

func (*Service) GetStored

func (r *Service) GetStored() ([]model.Model, error)

func (*Service) Reconcile

func (r *Service) Reconcile() error

func (*Service) Update

func (r *Service) Update(e event.UpdateEvent) bool

type SimpleReconciler

type SimpleReconciler struct {
	// A database connection.
	Db *sql.DB
}

A basic Reconciler. The term is borrowed from k8s and is similar but different. Using the `GetDiscovered()` and `GetStored()` methods, a disposition is constructed and used to update the DB.

func (*SimpleReconciler) Reconcile

func (r *SimpleReconciler) Reconcile(collection Collection) (err error)

Reconcile the resources on the cluster and the collection in the DB. Using the `GetDiscovered()` and `GetStored()` methods, a disposition is constructed and used to update the DB.

type StorageClass

type StorageClass struct {
	// Base
	BaseCollection
}

A collection of k8s StorageClass resources.

func (*StorageClass) AddWatch

func (r *StorageClass) AddWatch(dsController controller.Controller) error

func (*StorageClass) Create

func (r *StorageClass) Create(e event.CreateEvent) bool

func (*StorageClass) Delete

func (r *StorageClass) Delete(e event.DeleteEvent) bool

func (*StorageClass) Generic

func (r *StorageClass) Generic(e event.GenericEvent) bool

func (*StorageClass) GetDiscovered

func (r *StorageClass) GetDiscovered() ([]model.Model, error)

func (*StorageClass) GetStored

func (r *StorageClass) GetStored() ([]model.Model, error)

func (*StorageClass) Reconcile

func (r *StorageClass) Reconcile() error

func (*StorageClass) Update

func (r *StorageClass) Update(e event.UpdateEvent) bool

type VirtualMachine

type VirtualMachine struct {
	// Base
	BaseCollection
}

A collection of k8s VirtualMachine resources.

func (*VirtualMachine) AddWatch

func (r *VirtualMachine) AddWatch(dsController controller.Controller) error

func (*VirtualMachine) Create

func (r *VirtualMachine) Create(e event.CreateEvent) bool

func (*VirtualMachine) Delete

func (r *VirtualMachine) Delete(e event.DeleteEvent) bool

func (*VirtualMachine) Generic

func (r *VirtualMachine) Generic(e event.GenericEvent) bool

func (*VirtualMachine) GetDiscovered

func (r *VirtualMachine) GetDiscovered() ([]model.Model, error)

func (*VirtualMachine) GetStored

func (r *VirtualMachine) GetStored() ([]model.Model, error)

func (*VirtualMachine) Reconcile

func (r *VirtualMachine) Reconcile() error

func (*VirtualMachine) Update

func (r *VirtualMachine) Update(e event.UpdateEvent) bool

Jump to

Keyboard shortcuts

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