database

package
v0.0.0-...-5518454 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package database provides the database access functions and schema.

Index

Constants

This section is empty.

Variables

SchemaExtensions is a list of schema extensions that can be passed to the MicroCluster daemon. Each entry will increase the database schema version by one, and will be applied after internal schema updates.

Functions

func AddSystemIDToNodes

func AddSystemIDToNodes(_ context.Context, tx *sql.Tx) error

AddSystemIDToNodes is schema update for table nodes

func ConfigItemExists

func ConfigItemExists(ctx context.Context, tx *sql.Tx, key string) (bool, error)

ConfigItemExists checks if a ConfigItem with the given key exists. generator: ConfigItem Exists

func ConfigSchemaUpdate

func ConfigSchemaUpdate(_ context.Context, tx *sql.Tx) error

ConfigSchemaUpdate is schema for table config

func CreateConfigItem

func CreateConfigItem(ctx context.Context, tx *sql.Tx, object ConfigItem) (int64, error)

CreateConfigItem adds a new ConfigItem to the database. generator: ConfigItem Create

func CreateFeatureGate

func CreateFeatureGate(ctx context.Context, tx *sql.Tx, object FeatureGate) (int64, error)

CreateFeatureGate creates a new FeatureGate.

func CreateJujuUser

func CreateJujuUser(ctx context.Context, tx *sql.Tx, object JujuUser) (int64, error)

CreateJujuUser adds a new JujuUser to the database. generator: JujuUser Create

func CreateManifestItem

func CreateManifestItem(ctx context.Context, tx *sql.Tx, object ManifestItem) (int64, error)

CreateManifestItem adds a new ManifestItem to the database. generator: ManifestItem Create

func CreateNode

func CreateNode(ctx context.Context, tx *sql.Tx, object Node) (int64, error)

CreateNode adds a new node to the database. generator: node Create

func CreateStorageBackend

func CreateStorageBackend(ctx context.Context, tx *sql.Tx, object StorageBackend) (int64, error)

CreateStorageBackend adds a new StorageBackend to the database. generator: StorageBackend Create

func DeleteConfigItem

func DeleteConfigItem(_ context.Context, tx *sql.Tx, key string) error

DeleteConfigItem deletes the ConfigItem matching the given key parameters. generator: ConfigItem DeleteOne-by-Key

func DeleteFeatureGate

func DeleteFeatureGate(ctx context.Context, tx *sql.Tx, gateKey string) error

DeleteFeatureGate deletes a FeatureGate by gate_key.

func DeleteJujuUser

func DeleteJujuUser(_ context.Context, tx *sql.Tx, username string) error

DeleteJujuUser deletes the JujuUser matching the given key parameters. generator: JujuUser DeleteOne-by-Username

func DeleteManifestItem

func DeleteManifestItem(_ context.Context, tx *sql.Tx, manifestID string) error

DeleteManifestItem deletes the ManifestItem matching the given key parameters. generator: ManifestItem DeleteOne-by-ManifestID

func DeleteNode

func DeleteNode(_ context.Context, tx *sql.Tx, name string) error

DeleteNode deletes the node matching the given key parameters. generator: node DeleteOne-by-Name

func DeleteStorageBackend

func DeleteStorageBackend(_ context.Context, tx *sql.Tx, name string) error

DeleteStorageBackend deletes the StorageBackend matching the given key parameters. generator: StorageBackend DeleteOne-by-Name

func FeatureGateExists

func FeatureGateExists(ctx context.Context, tx *sql.Tx, gateKey string) (bool, error)

FeatureGateExists checks if a FeatureGate exists by gate_key.

func FeatureGatesSchemaUpdate

func FeatureGatesSchemaUpdate(_ context.Context, tx *sql.Tx) error

FeatureGatesSchemaUpdate is schema for table feature_gates

func GetConfigItemID

func GetConfigItemID(ctx context.Context, tx *sql.Tx, key string) (int64, error)

GetConfigItemID return the ID of the ConfigItem with the given key. generator: ConfigItem ID

func GetConfigItemKeys

func GetConfigItemKeys(ctx context.Context, tx *sql.Tx, prefix *string) ([]string, error)

GetConfigItemKeys returns the list of ConfigItem keys from the database, filtered by prefix if provided.

func GetFeatureGateID

func GetFeatureGateID(ctx context.Context, tx *sql.Tx, gateKey string) (int64, error)

GetFeatureGateID returns the ID of a FeatureGate by gate_key.

func GetJujuUserID

func GetJujuUserID(ctx context.Context, tx *sql.Tx, username string) (int64, error)

GetJujuUserID return the ID of the JujuUser with the given key. generator: JujuUser ID

func GetManifestItemID

func GetManifestItemID(ctx context.Context, tx *sql.Tx, manifestID string) (int64, error)

GetManifestItemID return the ID of the ManifestItem with the given key. generator: ManifestItem ID

func GetNodeID

func GetNodeID(ctx context.Context, tx *sql.Tx, name string) (int64, error)

GetNodeID return the ID of the node with the given key. generator: node ID

func GetStorageBackendID

func GetStorageBackendID(ctx context.Context, tx *sql.Tx, name string) (int64, error)

GetStorageBackendID return the ID of the StorageBackend with the given key. generator: StorageBackend ID

func JujuUserExists

func JujuUserExists(ctx context.Context, tx *sql.Tx, username string) (bool, error)

JujuUserExists checks if a JujuUser with the given key exists. generator: JujuUser Exists

func JujuUserSchemaUpdate

func JujuUserSchemaUpdate(_ context.Context, tx *sql.Tx) error

JujuUserSchemaUpdate is schema for table jujuuser

func ManifestItemExists

func ManifestItemExists(ctx context.Context, tx *sql.Tx, manifestID string) (bool, error)

ManifestItemExists checks if a ManifestItem with the given key exists. generator: ManifestItem Exists

func ManifestsSchemaUpdate

func ManifestsSchemaUpdate(_ context.Context, tx *sql.Tx) error

ManifestsSchemaUpdate is schema for table manifest TOCHK: TIMESTAMP(6) not storing nano seconds

func NodeExists

func NodeExists(ctx context.Context, tx *sql.Tx, name string) (bool, error)

NodeExists checks if a node with the given key exists. generator: node Exists

func NodesSchemaUpdate

func NodesSchemaUpdate(_ context.Context, tx *sql.Tx) error

NodesSchemaUpdate is schema for table nodes

func StorageBackendExists

func StorageBackendExists(ctx context.Context, tx *sql.Tx, name string) (bool, error)

StorageBackendExists checks if a StorageBackend with the given key exists. generator: StorageBackend Exists

func StorageBackendSchemaUpdate

func StorageBackendSchemaUpdate(_ context.Context, tx *sql.Tx) error

StorageBackendSchemaUpdate is schema for table storage_backends

func UpdateConfigItem

func UpdateConfigItem(ctx context.Context, tx *sql.Tx, key string, object ConfigItem) error

UpdateConfigItem updates the ConfigItem matching the given key parameters. generator: ConfigItem Update

func UpdateFeatureGate

func UpdateFeatureGate(ctx context.Context, tx *sql.Tx, gateKey string, object FeatureGate) error

UpdateFeatureGate updates a FeatureGate.

func UpdateJujuUser

func UpdateJujuUser(ctx context.Context, tx *sql.Tx, username string, object JujuUser) error

UpdateJujuUser updates the JujuUser matching the given key parameters. generator: JujuUser Update

func UpdateNode

func UpdateNode(ctx context.Context, tx *sql.Tx, name string, object Node) error

UpdateNode updates the node matching the given key parameters. generator: node Update

func UpdateStorageBackend

func UpdateStorageBackend(ctx context.Context, tx *sql.Tx, name string, object StorageBackend) error

UpdateStorageBackend updates the StorageBackend matching the given key parameters. generator: StorageBackend Update

Types

type ConfigItem

type ConfigItem struct {
	ID    int
	Key   string `db:"primary=yes"`
	Value string
}

ConfigItem is used to track the Ceph configuration.

func GetConfigItem

func GetConfigItem(ctx context.Context, tx *sql.Tx, key string) (*ConfigItem, error)

GetConfigItem returns the ConfigItem with the given key. generator: ConfigItem GetOne

func GetConfigItems

func GetConfigItems(ctx context.Context, tx *sql.Tx, filters ...ConfigItemFilter) ([]ConfigItem, error)

GetConfigItems returns all available ConfigItems. generator: ConfigItem GetMany

type ConfigItemFilter

type ConfigItemFilter struct {
	Key *string
}

ConfigItemFilter is a required struct for use with lxd-generate. It is used for filtering fields on database fetches.

type FeatureGate

type FeatureGate struct {
	ID      int
	GateKey string `db:"primary=yes"`
	Enabled bool
}

FeatureGate is used to track feature gate configuration.

func GetFeatureGate

func GetFeatureGate(ctx context.Context, tx *sql.Tx, gateKey string) (FeatureGate, error)

GetFeatureGate returns a single FeatureGate by gate_key.

func GetFeatureGates

func GetFeatureGates(ctx context.Context, tx *sql.Tx) ([]FeatureGate, error)

GetFeatureGates returns all available FeatureGates.

type FeatureGateFilter

type FeatureGateFilter struct {
	GateKey *string
}

FeatureGateFilter is a required struct for use with lxd-generate. It is used for filtering fields on database fetches.

type JujuUser

type JujuUser struct {
	ID       int
	Username string `db:"primary=yes"`
	Token    string
}

JujuUser is used to track User and registration token information.

func GetJujuUser

func GetJujuUser(ctx context.Context, tx *sql.Tx, username string) (*JujuUser, error)

GetJujuUser returns the JujuUser with the given key. generator: JujuUser GetOne

func GetJujuUsers

func GetJujuUsers(ctx context.Context, tx *sql.Tx, filters ...JujuUserFilter) ([]JujuUser, error)

GetJujuUsers returns all available JujuUsers. generator: JujuUser GetMany

type JujuUserFilter

type JujuUserFilter struct {
	Username *string
}

JujuUserFilter is a required struct for use with lxd-generate. It is used for filtering fields on database fetches.

type ManifestItem

type ManifestItem struct {
	ID          int
	ManifestID  string `db:"primary=yes"`
	AppliedDate string
	Data        string
}

ManifestItem is used to save the Sunbeam manifests provided by user. AppliedDate is saved as Timestamp in database but retreived as string Probable Bug: https://github.com/mattn/go-sqlite3/issues/951

func GetLatestManifestItem

func GetLatestManifestItem(ctx context.Context, tx *sql.Tx) (*ManifestItem, error)

GetLatestManifestItem returns the latest inserted record in manifest table.

func GetManifestItem

func GetManifestItem(ctx context.Context, tx *sql.Tx, manifestID string) (*ManifestItem, error)

GetManifestItem returns the ManifestItem with the given key. generator: ManifestItem GetOne

func GetManifestItems

func GetManifestItems(ctx context.Context, tx *sql.Tx, filters ...ManifestItemFilter) ([]ManifestItem, error)

GetManifestItems returns all available ManifestItems. generator: ManifestItem GetMany

type ManifestItemFilter

type ManifestItemFilter struct {
	ManifestID *string
}

ManifestItemFilter is a required struct for use with lxd-generate. It is used for filtering fields on database fetches.

type Node

type Node struct {
	ID        int
	Member    string `db:"join=core_cluster_members.name&joinon=nodes.member_id"`
	Name      string `db:"primary=yes"`
	Role      string
	MachineID int
	SystemID  string
}

Node is used to track Node information.

func GetNode

func GetNode(ctx context.Context, tx *sql.Tx, name string) (*Node, error)

GetNode returns the node with the given key. generator: node GetOne

func GetNodes

func GetNodes(ctx context.Context, tx *sql.Tx, filters ...NodeFilter) ([]Node, error)

GetNodes returns all available nodes. generator: node GetMany

func GetNodesFromRoles

func GetNodesFromRoles(ctx context.Context, tx *sql.Tx, roles []string) ([]Node, error)

GetNodesFromRoles returns a slice of Nodes that match the given roles.

type NodeFilter

type NodeFilter struct {
	Member    *string
	Name      *string
	Role      *string
	MachineID *int
}

NodeFilter is a required struct for use with lxd-generate. It is used for filtering fields on database fetches.

type StorageBackend

type StorageBackend struct {
	ID        int
	Name      string `db:"primary=yes"`
	Type      string
	Config    string
	Principal string
	ModelUUID string
}

StorageBackend is used to track StorageBackend information.

func GetStorageBackend

func GetStorageBackend(ctx context.Context, tx *sql.Tx, name string) (*StorageBackend, error)

GetStorageBackend returns the StorageBackend with the given key. generator: StorageBackend GetOne

func GetStorageBackends

func GetStorageBackends(ctx context.Context, tx *sql.Tx, filters ...StorageBackendFilter) ([]StorageBackend, error)

GetStorageBackends returns all available StorageBackends. generator: StorageBackend GetMany

type StorageBackendFilter

type StorageBackendFilter struct {
	Name      *string
	Type      *string
	Principal *string
	ModelUUID *string
}

StorageBackendFilter is a required struct for use with lxd-generate. It is used for filtering fields on database fetches.

Jump to

Keyboard shortcuts

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