databaseprovider

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIServerOptions

type APIServerOptions struct {
	// Context configures the Kubernetes context name to use for the connection. Use this for NON-production scenarios to test
	// against a specific cluster.
	Context string `yaml:"context"`

	// Namespace configures the Kubernetes namespace used for data-storage. The namespace must already exist.
	Namespace string `yaml:"namespace"`
}

APIServerOptions represents options for the configuring the Kubernetes APIServer store.

type DatabaseProvider

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

DatabaseProvider acts as a factory for database clients.

Do not use construct this directly:

- Use FromOptions instead for production use. - Use FromMemory or FromClient for testing.

func FromClient

func FromClient(client database.Client) *DatabaseProvider

FromClient creates a new instance of the DatabaseProvider struct with the given client.

This will always return the given client and will not attempt to create a new one. This can be used for testing with mocks.

func FromMemory

func FromMemory() *DatabaseProvider

FromMemory creates a new instance of the DatabaseProvider struct using the in-memory client.

This will use the ephemeral in-memory database client.

func FromOptions

func FromOptions(options Options) *DatabaseProvider

FromOptions creates a new instance of the DatabaseProvider struct with the given options.

This will used the known factory functions to instantiate the database client.

func (*DatabaseProvider) GetClient

func (p *DatabaseProvider) GetClient(ctx context.Context) (database.Client, error)

GetClient returns a database client for the given resource type.

type DatabaseProviderType

type DatabaseProviderType string

DatabaseProviderType represents types of database provider.

const (
	// TypeAPIServer represents the Kubernetes APIServer provider.
	TypeAPIServer DatabaseProviderType = "apiserver"

	// TypeInMemory represents the in-memory provider.
	TypeInMemory DatabaseProviderType = "inmemory"

	// TypePostgreSQL represents the PostgreSQL provider.
	TypePostgreSQL DatabaseProviderType = "postgresql"
)

type InMemoryOptions

type InMemoryOptions struct{}

InMemoryOptions represents options for the in-memory store.

type Options

type Options struct {
	// Provider configures the database provider.
	Provider DatabaseProviderType `yaml:"provider"`

	// APIServer configures options for the Kubernetes APIServer store. Will be ignored if another store is configured.
	APIServer APIServerOptions `yaml:"apiserver,omitempty"`

	// InMemory configures options for the in-memory store. Will be ignored if another store is configured.
	InMemory InMemoryOptions `yaml:"inmemory,omitempty"`

	// PostgreSQL configures options for connecting to a PostgreSQL database. Will be ignored if another store is configured.
	PostgreSQL PostgreSQLOptions `yaml:"postgresql,omitempty"`
}

Options represents the database provider options.

type PostgreSQLOptions

type PostgreSQLOptions struct {
	// URL is the connection information for the PostgreSQL database in URL format.
	//
	// The URL should be formatted according to:
	// https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS
	//
	// The URL can contain secrets like passwords so it must be treated as sensitive.
	//
	// In place of the actual URL, you can substitute an environment variable by using the format:
	// 	${ENV_VAR_NAME}
	URL string `yaml:"url"`
}

PostgreSQLOptions represents options for the PostgreSQL store.

Jump to

Keyboard shortcuts

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