external

package
v0.0.0-...-810ebbb Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package external provides access to external data sources for scheduling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NovaReader

type NovaReader struct {
	*PostgresReader
}

NovaReader provides read access to Nova data stored in the database. It uses a PostgresReader to connect to the database.

func NewNovaReader

func NewNovaReader(reader *PostgresReader) *NovaReader

NewNovaReader creates a new NovaReader from a PostgresReader.

func (*NovaReader) GetAllAggregates

func (r *NovaReader) GetAllAggregates(ctx context.Context) ([]nova.Aggregate, error)

GetAllAggregates returns all Nova aggregates from the database.

func (*NovaReader) GetAllFlavors

func (r *NovaReader) GetAllFlavors(ctx context.Context) ([]nova.Flavor, error)

GetAllFlavors returns all Nova flavors from the database.

func (*NovaReader) GetAllHypervisors

func (r *NovaReader) GetAllHypervisors(ctx context.Context) ([]nova.Hypervisor, error)

GetAllHypervisors returns all Nova hypervisors from the database.

func (*NovaReader) GetAllMigrations

func (r *NovaReader) GetAllMigrations(ctx context.Context) ([]nova.Migration, error)

GetAllMigrations returns all Nova migrations from the database.

func (*NovaReader) GetAllServers

func (r *NovaReader) GetAllServers(ctx context.Context) ([]nova.Server, error)

GetAllServers returns all Nova servers from the database.

func (*NovaReader) GetDeletedServerByID

func (r *NovaReader) GetDeletedServerByID(ctx context.Context, serverID string) (*nova.DeletedServer, error)

GetDeletedServerByID returns a deleted Nova server by its ID from the deleted_servers table. Returns nil, nil if the server is not found in the deleted_servers table.

func (*NovaReader) GetFlavorByName

func (r *NovaReader) GetFlavorByName(ctx context.Context, flavorName string) (*nova.Flavor, error)

GetFlavorByName returns a Nova flavor by its name. Returns nil, nil if the flavor is not found.

func (*NovaReader) GetServerByID

func (r *NovaReader) GetServerByID(ctx context.Context, serverID string) (*nova.Server, error)

GetServerByID returns a Nova server by its ID. Returns nil, nil if the server is not found.

type NovaReaderInterface

type NovaReaderInterface interface {
	GetAllServers(ctx context.Context) ([]nova.Server, error)
	GetAllFlavors(ctx context.Context) ([]nova.Flavor, error)
	GetServerByID(ctx context.Context, serverID string) (*nova.Server, error)
	GetFlavorByName(ctx context.Context, flavorName string) (*nova.Flavor, error)
	// GetDeletedServerByID returns a deleted server by its ID from the deleted_servers table.
	// Returns nil, nil if the server is not found in the deleted_servers table.
	GetDeletedServerByID(ctx context.Context, serverID string) (*nova.DeletedServer, error)
}

NovaReaderInterface defines the methods needed to read Nova data. This interface allows mocking the NovaReader in tests.

type PostgresReader

type PostgresReader struct {
	// Kubernetes client to read the Datasource CRD and secrets.
	Client client.Client
	// Reference to the database secret containing connection info.
	DatabaseSecretRef corev1.SecretReference
	// contains filtered or unexported fields
}

PostgresReader provides read access to a postgres database. It reads the database connection info from a Datasource CRD.

func NewPostgresReader

func NewPostgresReader(ctx context.Context, c client.Client, datasourceName string) (*PostgresReader, error)

NewPostgresReader creates a new PostgresReader from a Datasource CRD name. It looks up the Datasource CRD to get the database secret reference.

func (*PostgresReader) DB

func (r *PostgresReader) DB(ctx context.Context) (*db.DB, error)

DB returns the database connection, initializing it if necessary. This method is safe for concurrent use.

func (*PostgresReader) Select

func (r *PostgresReader) Select(ctx context.Context, dest any, query string, args ...any) error

Select executes a SELECT query and returns the results.

Jump to

Keyboard shortcuts

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