sqlite

package
v0.0.0-...-278bb9c Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package sqlite defines an implementation for the store as an SQLite database

Index

Constants

View Source
const InMemoryPath = "file::memory:"

InMemoryPath is the path inside the memory pointing to the database

Variables

This section is empty.

Functions

func NewSqliteStore

func NewSqliteStore(dbpath string) (database.Store, error)

NewSqliteStore creates the database storage using the given string as the database file.

Types

type Store

type Store struct {
	*gorm.DB
}

Store is the database structure

func (Store) AddBootSetupToMachine

func (s Store) AddBootSetupToMachine(bootSetup *images.BootSetup) error

AddBootSetupToMachine adds a configuration for booting to the specified machine

func (Store) AddImageToImageSetup

func (s Store) AddImageToImageSetup(setup *images.ImageSetup, image *images.ImageModel, version images.Version,
	update bool)

AddImageToImageSetup adds an image pegged to a particular version to the setup.

func (Store) CreateImage

func (s Store) CreateImage(image *images.ImageModel)

CreateImage creates the image entity in the database and adds the first version to it.

func (Store) CreateImageSetup

func (s Store) CreateImageSetup(username string, image *images.ImageSetup) error

CreateImageSetup creates a collection of images in history.

func (Store) CreateMachine

func (s Store) CreateMachine(machine *machine.MachineModel) error

CreateMachine creates the machine in the database

func (Store) CreateMachineImage

func (s Store) CreateMachineImage(image *images.MachineImageModel)

CreateMachineImage creates the image entity in the database and adds the first version to it.

func (Store) CreateNewImageVersion

func (s Store) CreateNewImageVersion(version images.Version)

CreateNewImageVersion creates a new version in the database

func (Store) CreateUser

func (s Store) CreateUser(user *user.UserModel) error

CreateUser creates a new user

func (Store) DeleteImage

func (s Store) DeleteImage(image *images.ImageModel) error

DeleteImage removes an image from the database

func (Store) DeleteImageSetup

func (s Store) DeleteImageSetup(imageSetup *images.ImageSetup) error

DeleteImageSetup deletes an image setup

func (Store) DeleteMachine

func (s Store) DeleteMachine(machine *machine.MachineModel) error

DeleteMachine removes a machine from the database

func (Store) FindImageSetupsByUsername

func (s Store) FindImageSetupsByUsername(username string) (*[]images.ImageSetup, error)

FindImageSetupsByUsername finds all ImageSetups associated with a particular user.

func (Store) GetImageByUUID

func (s Store) GetImageByUUID(uuid images.ImageUUID) (*images.ImageModel, error)

GetImageByUUID fetches the image with the versions using their UUID as a key

func (Store) GetImageSetup

func (s Store) GetImageSetup(uuid string) (images.ImageSetup, error)

GetImageSetup an image setup associated with a particular UUID.

func (Store) GetImageSetups

func (s Store) GetImageSetups(username string) (*[]images.ImageSetup, error)

GetImageSetups finds the image setups associated with a user

func (Store) GetImagesByNameAndUsername

func (s Store) GetImagesByNameAndUsername(name string, username string) ([]images.ImageModel, error)

GetImagesByNameAndUsername gets all the images associated with a user which have the same human-readable name. This theoretically possible, but it is unsure whether this actually holds in any real-world scenario.

func (Store) GetImagesByUsername

func (s Store) GetImagesByUsername(username string) ([]images.ImageModel, error)

GetImagesByUsername fetches all the images associated to a user.

func (Store) GetMachineByMac

func (s Store) GetMachineByMac(mac util.MacAddress) (*machine.MachineModel, error)

GetMachineByMac gets any machine with the associated MAC addresses from the database

func (Store) GetMachineImageByMac

func (s Store) GetMachineImageByMac(mac util.MacAddress) (*images.MachineImageModel, error)

GetMachineImageByMac fetches the image with the versions using mac address of their machine as a key

func (Store) GetMachineImageByUUID

func (s Store) GetMachineImageByUUID(uuid images.ImageUUID) (*images.MachineImageModel, error)

GetMachineImageByUUID gets the machine image associated with a UUID

func (Store) GetMachines

func (s Store) GetMachines() (machines []machine.MachineModel, _ error)

GetMachines returns the values in the machine_models database. TODO: Fetch foreign relations.

func (Store) GetNextBootSetup

func (s Store) GetNextBootSetup(machineMAC string) (*images.BootSetup, error)

GetNextBootSetup fetches the first machine from the database.

func (Store) GetUserByID

func (s Store) GetUserByID(id uint) (*user.UserModel, error)

GetUserByID gets the user with the specified id from the database.

func (Store) GetUserByUsername

func (s Store) GetUserByUsername(name string) (*user.UserModel, error)

GetUserByUsername gets the first user with the associated username from the database.

func (Store) GetUsers

func (s Store) GetUsers() (users []user.UserModel, _ error)

GetUsers gets all the users out of the database.

func (Store) GetVersionByID

func (s Store) GetVersionByID(versionID uint64) (*images.Version, error)

GetVersionByID gets the version associated with a specific ID

func (Store) ModifyImageSetup

func (s Store) ModifyImageSetup(imageSetup *images.ImageSetup) error

ModifyImageSetup changes the metadata of an image setup

func (Store) ModifyUser

func (s Store) ModifyUser(user *user.UserModel) error

ModifyUser modifies a user

func (Store) RemoveImageFromImageSetup

func (s Store) RemoveImageFromImageSetup(setup *images.ImageSetup, targetImage *images.ImageModel, version images.Version, update bool) error

RemoveImageFromImageSetup removes a particular iamge from the image setup

func (Store) RemoveUser

func (s Store) RemoveUser(user *user.UserModel) error

RemoveUser deletes a user from the database

func (Store) UpdateImage

func (s Store) UpdateImage(image *images.ImageModel) error

UpdateImage updates an image in the database

func (Store) UpdateMachine

func (s Store) UpdateMachine(machine *machine.MachineModel) error

UpdateMachine updates the information about the machine or creates a machine where one does not yet exist.

Jump to

Keyboard shortcuts

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