Documentation
¶
Index ¶
- Constants
- Variables
- func Begin(db *sql.DB) (*sql.Tx, error)
- func CertDelete(db *sql.DB, fingerprint string) error
- func CertSave(db *sql.DB, cert *CertInfo) error
- func CertUpdate(db *sql.DB, fingerprint string, certName string, certType int) error
- func ConfigValueSet(db *sql.DB, key string, value string) error
- func ConfigValuesGet(db *sql.DB) (map[string]string, error)
- func ContainerConfig(db *sql.DB, containerId int) (map[string]string, error)
- func ContainerConfigClear(tx *sql.Tx, id int) error
- func ContainerConfigGet(db *sql.DB, id int, key string) (string, error)
- func ContainerConfigInsert(tx *sql.Tx, id int, config map[string]string) error
- func ContainerConfigRemove(db *sql.DB, id int, name string) error
- func ContainerCreate(db *sql.DB, args ContainerArgs) (int, error)
- func ContainerGetSnapshots(db *sql.DB, name string) ([]string, error)
- func ContainerId(db *sql.DB, name string) (int, error)
- func ContainerLastUsedUpdate(db *sql.DB, id int, date time.Time) error
- func ContainerName(db *sql.DB, id int) (string, error)
- func ContainerPool(db *sql.DB, containerName string) (string, error)
- func ContainerProfiles(db *sql.DB, containerId int) ([]string, error)
- func ContainerProfilesInsert(tx *sql.Tx, id int, profiles []string) error
- func ContainerRemove(db *sql.DB, name string) error
- func ContainerRename(db *sql.DB, oldName string, newName string) error
- func ContainerSetState(db *sql.DB, id int, state string) error
- func ContainerSetStateful(db *sql.DB, id int, stateful bool) error
- func ContainerUpdate(tx *sql.Tx, id int, description string, architecture int, ephemeral bool) error
- func ContainersList(db *sql.DB, cType ContainerType) ([]string, error)
- func CreateDb(db *sql.DB, patchNames []string) (err error)
- func Devices(db *sql.DB, qName string, isprofile bool) (types.Devices, error)
- func DevicesAdd(tx *sql.Tx, w string, cID int64, devices types.Devices) error
- func Exec(db *sql.DB, q string, args ...interface{}) (sql.Result, error)
- func GetLatestSchema() int
- func GetSchema(db *sql.DB) (v int)
- func ImageAliasAdd(db *sql.DB, name string, imageID int, desc string) error
- func ImageAliasDelete(db *sql.DB, name string) error
- func ImageAliasGet(db *sql.DB, name string, isTrustedClient bool) (int, api.ImageAliasesEntry, error)
- func ImageAliasRename(db *sql.DB, id int, name string) error
- func ImageAliasUpdate(db *sql.DB, id int, imageID int, desc string) error
- func ImageAliasesMove(db *sql.DB, source int, destination int) error
- func ImageDelete(db *sql.DB, id int) error
- func ImageExists(db *sql.DB, fingerprint string) (bool, error)
- func ImageGet(db *sql.DB, fingerprint string, public bool, strictMatching bool) (int, *api.Image, error)
- func ImageGetPoolNamesFromIDs(db *sql.DB, poolIDs []int64) ([]string, error)
- func ImageGetPools(db *sql.DB, imageFingerprint string) ([]int64, error)
- func ImageInsert(db *sql.DB, fp string, fname string, sz int64, public bool, autoUpdate bool, ...) error
- func ImageLastAccessInit(db *sql.DB, fingerprint string) error
- func ImageLastAccessUpdate(db *sql.DB, fingerprint string, date time.Time) error
- func ImageSourceGet(db *sql.DB, imageId int) (int, api.ImageSource, error)
- func ImageSourceGetCachedFingerprint(db *sql.DB, server string, protocol string, alias string) (string, error)
- func ImageSourceInsert(db *sql.DB, imageId int, server string, protocol string, certificate string, ...) error
- func ImageUpdate(db *sql.DB, id int, fname string, sz int64, public bool, autoUpdate bool, ...) error
- func ImagesGet(db *sql.DB, public bool) ([]string, error)
- func ImagesGetExpired(db *sql.DB, expiry int64) ([]string, error)
- func IsDbLockedError(err error) bool
- func NetworkConfigAdd(tx *sql.Tx, id int64, config map[string]string) error
- func NetworkConfigClear(tx *sql.Tx, id int64) error
- func NetworkConfigGet(db *sql.DB, id int64) (map[string]string, error)
- func NetworkCreate(db *sql.DB, name, description string, config map[string]string) (int64, error)
- func NetworkDelete(db *sql.DB, name string) error
- func NetworkGet(db *sql.DB, name string) (int64, *api.Network, error)
- func NetworkGetInterface(db *sql.DB, devName string) (int64, *api.Network, error)
- func NetworkRename(db *sql.DB, oldName string, newName string) error
- func NetworkUpdate(db *sql.DB, name, description string, config map[string]string) error
- func NetworkUpdateDescription(tx *sql.Tx, id int64, description string) error
- func Networks(db *sql.DB) ([]string, error)
- func OpenDb(path string) (*sql.DB, error)
- func Patches(db *sql.DB) ([]string, error)
- func PatchesMarkApplied(db *sql.DB, patch string) error
- func ProfileConfig(db *sql.DB, name string) (map[string]string, error)
- func ProfileConfigAdd(tx *sql.Tx, id int64, config map[string]string) error
- func ProfileConfigClear(tx *sql.Tx, id int64) error
- func ProfileContainersGet(db *sql.DB, profile string) ([]string, error)
- func ProfileCreate(db *sql.DB, profile string, description string, config map[string]string, ...) (int64, error)
- func ProfileCreateDefault(db *sql.DB) error
- func ProfileDelete(db *sql.DB, name string) error
- func ProfileDescriptionUpdate(tx *sql.Tx, id int64, description string) error
- func ProfileGet(db *sql.DB, name string) (int64, *api.Profile, error)
- func ProfileUpdate(db *sql.DB, name string, newName string) error
- func Profiles(db *sql.DB) ([]string, error)
- func QueryScan(db *sql.DB, q string, inargs []interface{}, outfmt []interface{}) ([][]interface{}, error)
- func StoragePoolConfigAdd(tx *sql.Tx, poolID int64, poolConfig map[string]string) error
- func StoragePoolConfigClear(tx *sql.Tx, poolID int64) error
- func StoragePoolConfigGet(db *sql.DB, poolID int64) (map[string]string, error)
- func StoragePoolCreate(db *sql.DB, poolName string, poolDescription string, poolDriver string, ...) (int64, error)
- func StoragePoolDelete(db *sql.DB, poolName string) (*api.StoragePool, error)
- func StoragePoolGet(db *sql.DB, poolName string) (int64, *api.StoragePool, error)
- func StoragePoolGetID(db *sql.DB, poolName string) (int64, error)
- func StoragePoolUpdate(db *sql.DB, poolName, description string, poolConfig map[string]string) error
- func StoragePoolUpdateDescription(tx *sql.Tx, id int64, description string) error
- func StoragePoolVolumeCreate(db *sql.DB, volumeName, volumeDescription string, volumeType int, poolID int64, ...) (int64, error)
- func StoragePoolVolumeDelete(db *sql.DB, volumeName string, volumeType int, poolID int64) error
- func StoragePoolVolumeGetType(db *sql.DB, volumeName string, volumeType int, poolID int64) (int64, *api.StorageVolume, error)
- func StoragePoolVolumeGetTypeID(db *sql.DB, volumeName string, volumeType int, poolID int64) (int64, error)
- func StoragePoolVolumeRename(db *sql.DB, oldVolumeName string, newVolumeName string, volumeType int, ...) error
- func StoragePoolVolumeTypeToName(volumeType int) (string, error)
- func StoragePoolVolumeUpdate(db *sql.DB, volumeName string, volumeType int, poolID int64, ...) error
- func StoragePoolVolumesGet(db *sql.DB, poolID int64, volumeTypes []int) ([]*api.StorageVolume, error)
- func StoragePoolVolumesGetNames(db *sql.DB, poolID int64) (int, error)
- func StoragePoolVolumesGetType(db *sql.DB, volumeType int, poolID int64) ([]string, error)
- func StoragePools(db *sql.DB) ([]string, error)
- func StoragePoolsGetDrivers(db *sql.DB) ([]string, error)
- func StorageVolumeConfigAdd(tx *sql.Tx, volumeID int64, volumeConfig map[string]string) error
- func StorageVolumeConfigClear(tx *sql.Tx, volumeID int64) error
- func StorageVolumeConfigGet(db *sql.DB, volumeID int64) (map[string]string, error)
- func StorageVolumeDescriptionGet(db *sql.DB, volumeID int64) (string, error)
- func StorageVolumeDescriptionUpdate(tx *sql.Tx, volumeID int64, description string) error
- func TxCommit(tx *sql.Tx) error
- func UpdatesApplyAll(db *sql.DB, doBackup bool, postApply func(int) error) error
- type CertInfo
- type ContainerArgs
- type ContainerType
Constants ¶
const ( StoragePoolVolumeTypeContainer = iota StoragePoolVolumeTypeImage StoragePoolVolumeTypeCustom )
XXX: this was extracted from apollo/storage_volume_utils.go, we find a way to
factor it independently from both the db and main packages.
const ( StoragePoolVolumeTypeNameContainer string = "container" StoragePoolVolumeTypeNameImage string = "image" StoragePoolVolumeTypeNameCustom string = "custom" )
Leave the string type in here! This guarantees that go treats this is as a typed string constant. Removing it causes go to treat these as untyped string constants which is not what we want.
const CURRENT_SCHEMA string = `` /* 6495-byte string literal not displayed */
CURRENT_SCHEMA contains the current SQLite SQL Schema.
Variables ¶
var ( // DbErrAlreadyDefined hapens when the given entry already exists, // for example a container. DbErrAlreadyDefined = fmt.Errorf("The container/snapshot already exists") /* NoSuchObjectError is in the case of joins (and probably other) queries, * we don't get back sql.ErrNoRows when no rows are returned, even though we do * on selects without joins. Instead, you can use this error to * propagate up and generate proper 404s to the client when something * isn't found so we don't abuse sql.ErrNoRows any more than we * already do. */ NoSuchObjectError = fmt.Errorf("No such object") )
var ImageSourceProtocol = map[int]string{
0: "apollo",
1: "direct",
2: "simplestreams",
}
Functions ¶
func CertDelete ¶
CertDelete deletes a certificate from the db.
func CertSave ¶
CertSave stores a CertBaseInfo object in the db, it will ignore the ID field from the CertInfo.
func CertUpdate ¶
func ContainerConfig ¶
ContainerConfig gets the container configuration map from the DB
func ContainerConfigInsert ¶
func ContainerCreate ¶
func ContainerCreate(db *sql.DB, args ContainerArgs) (int, error)
func ContainerLastUsedUpdate ¶
func ContainerPool ¶
Get the storage pool of a given container.
func ContainerProfiles ¶
Get a list of profiles for a given container id.
func ContainerProfilesInsert ¶
func ContainerUpdate ¶
func ContainersList ¶
func ContainersList(db *sql.DB, cType ContainerType) ([]string, error)
func GetLatestSchema ¶
func GetLatestSchema() int
func ImageAliasAdd ¶
Insert an alias ento the database.
func ImageAliasGet ¶
func ImageExists ¶
Whether an image with the given fingerprint exists.
func ImageGet ¶
func ImageGet(db *sql.DB, fingerprint string, public bool, strictMatching bool) (int, *api.Image, error)
ImageGet gets an Image object from the database. If strictMatching is false, The fingerprint argument will be queried with a LIKE query, means you can pass a shortform and will get the full fingerprint. There can never be more than one image with a given fingerprint, as it is enforced by a UNIQUE constraint in the schema.
func ImageGetPoolNamesFromIDs ¶
Get the names of all storage pools on which a given image exists.
func ImageGetPools ¶
Get the names of all storage pools on which a given image exists.
func ImageInsert ¶
func ImageLastAccessUpdate ¶
func ImageSourceGet ¶
func ImageSourceGetCachedFingerprint ¶
func ImageSourceGetCachedFingerprint(db *sql.DB, server string, protocol string, alias string) (string, error)
Try to find a source entry of a locally cached image that matches the given remote details (server, protocol and alias). Return the fingerprint linked to the matching entry, if any.
func ImageSourceInsert ¶
func ImageUpdate ¶
func IsDbLockedError ¶
func NetworkCreate ¶
func NetworkGetInterface ¶
func NetworkUpdate ¶
func ProfileConfig ¶
Get the profile configuration map from the DB
func ProfileCreate ¶
func ProfileCreateDefault ¶
func QueryScan ¶
func QueryScan(db *sql.DB, q string, inargs []interface{}, outfmt []interface{}) ([][]interface{}, error)
* . q is the database query * . inargs is an array of interfaces containing the query arguments * . outfmt is an array of interfaces containing the right types of output * arguments, i.e. * var arg1 string * var arg2 int * outfmt := {}interface{}{arg1, arg2} * * The result will be an array (one per output row) of arrays (one per output argument) * of interfaces, containing pointers to the actual output arguments.
func StoragePoolConfigAdd ¶
Add new storage pool config.
func StoragePoolConfigClear ¶
Delete storage pool config.
func StoragePoolConfigGet ¶
Get config of a storage pool.
func StoragePoolCreate ¶
func StoragePoolCreate(db *sql.DB, poolName string, poolDescription string, poolDriver string, poolConfig map[string]string) (int64, error)
Create new storage pool.
func StoragePoolDelete ¶
Delete storage pool.
func StoragePoolGet ¶
Get a single storage pool.
func StoragePoolGetID ¶
Get id of a single storage pool.
func StoragePoolUpdate ¶
func StoragePoolUpdate(db *sql.DB, poolName, description string, poolConfig map[string]string) error
Update storage pool.
func StoragePoolUpdateDescription ¶
Update the storage pool description.
func StoragePoolVolumeCreate ¶
func StoragePoolVolumeCreate(db *sql.DB, volumeName, volumeDescription string, volumeType int, poolID int64, volumeConfig map[string]string) (int64, error)
Create new storage volume attached to a given storage pool.
func StoragePoolVolumeDelete ¶
Delete storage volume attached to a given storage pool.
func StoragePoolVolumeGetType ¶
func StoragePoolVolumeGetType(db *sql.DB, volumeName string, volumeType int, poolID int64) (int64, *api.StorageVolume, error)
Get a single storage volume attached to a given storage pool of a given type.
func StoragePoolVolumeGetTypeID ¶
func StoragePoolVolumeGetTypeID(db *sql.DB, volumeName string, volumeType int, poolID int64) (int64, error)
Get ID of a storage volume on a given storage pool of a given storage volume type.
func StoragePoolVolumeRename ¶
func StoragePoolVolumeRename(db *sql.DB, oldVolumeName string, newVolumeName string, volumeType int, poolID int64) error
Rename storage volume attached to a given storage pool.
func StoragePoolVolumeTypeToName ¶
StoragePoolVolumeTypeToName converts a volume integer type code to its human-readable name.
func StoragePoolVolumeUpdate ¶
func StoragePoolVolumeUpdate(db *sql.DB, volumeName string, volumeType int, poolID int64, volumeDescription string, volumeConfig map[string]string) error
Update storage volume attached to a given storage pool.
func StoragePoolVolumesGet ¶
func StoragePoolVolumesGet(db *sql.DB, poolID int64, volumeTypes []int) ([]*api.StorageVolume, error)
Get all storage volumes attached to a given storage pool.
func StoragePoolVolumesGetNames ¶
Get the names of all storage volumes attached to a given storage pool.
func StoragePoolVolumesGetType ¶
Get all storage volumes attached to a given storage pool of a given volume type.
func StoragePoolsGetDrivers ¶
Get the names of all storage volumes attached to a given storage pool.
func StorageVolumeConfigAdd ¶
Add new storage volume config into database.
func StorageVolumeConfigClear ¶
Delete storage volume config.
func StorageVolumeConfigGet ¶
Get config of a storage volume.
func StorageVolumeDescriptionGet ¶
Get the description of a storage volume.
func StorageVolumeDescriptionUpdate ¶
Update description of a storage volume.
func UpdatesApplyAll ¶
Apply all possible database patches. If "doBackup" is true, the sqlite file will be backed up before any update is applied. If "postApply" it's passed, it will be called after each database update gets successfully applied, and be passed the its version (as of now "postApply" is only used by the daemon as a mean to apply the legacy V10 and V15 non-db updates during the database upgrade sequence to, avoid changing semantics see PR #3322).
Types ¶
type CertInfo ¶
CertInfo is here to pass the certificates content from the database around
func CertGet ¶
CertGet gets an CertBaseInfo object from the database. The argument fingerprint will be queried with a LIKE query, means you can pass a shortform and will get the full fingerprint. There can never be more than one image with a given fingerprint, as it is enforced by a UNIQUE constraint in the schema.
type ContainerArgs ¶
type ContainerArgs struct {
// Don't set manually
Id int
Description string
Architecture int
BaseImage string
Config map[string]string
CreationDate time.Time
LastUsedDate time.Time
Ctype ContainerType
Devices types.Devices
Ephemeral bool
Name string
Profiles []string
Stateful bool
}
ContainerArgs is a value object holding all db-related details about a container.
func ContainerGet ¶
func ContainerGet(db *sql.DB, name string) (ContainerArgs, error)
type ContainerType ¶
type ContainerType int
ContainerType encodes the type of container (either regular or snapshot).
const ( CTypeRegular ContainerType = 0 CTypeSnapshot ContainerType = 1 )