database

package
v0.0.0-...-7c60cf1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 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 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 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 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 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 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 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 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 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

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 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.

Jump to

Keyboard shortcuts

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