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 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 ContainerName(db *sql.DB, id int) (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, 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 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 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 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(qi queryer, q string, inargs []interface{}, outfmt []interface{}) ([][]interface{}, error)
- func TxCommit(tx *sql.Tx) error
- func UpdateSchemaDotGo() error
- func UpdatesApplyAll(db *sql.DB, doBackup bool, legacyPatches map[int]*LegacyPatch) error
- type CertInfo
- type ContainerArgs
- type ContainerType
- type LegacyPatch
Constants ¶
const CURRENT_SCHEMA = `` /* 4706-byte string literal not displayed */
DO NOT EDIT BY HAND
This code was generated by the UpdateSchemaDotGo function. If you need to modify the database schema, please add a new schema update to update.go and the run 'make update-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: "lxd",
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 ContainerConfig ¶
ContainerConfig gets the container configuration map from the DB
func ContainerConfigInsert ¶
func ContainerCreate ¶
func ContainerCreate(db *sql.DB, args ContainerArgs) (int, error)
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 ImageInsert ¶
func ImageLastAccessUpdate ¶
func ImageSourceGet ¶
func ImageSourceInsert ¶
func ImageUpdate ¶
func IsDbLockedError ¶
func ProfileConfig ¶
Get the profile configuration map from the DB
func ProfileCreate ¶
func ProfileCreateDefault ¶
func QueryScan ¶
func QueryScan(qi queryer, q string, inargs []interface{}, outfmt []interface{}) ([][]interface{}, error)
* . qi anything implementing the querier interface (i.e. either sql.DB or sql.Tx) * . 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 UpdateSchemaDotGo ¶
func UpdateSchemaDotGo() error
UpdateSchemaDotGo rewrites the 'schema.go' source file in this package to match the current schema updates.
The schema.go file contains a "flattened" render of all schema updates defined in this file, and it's used to initialize brand new databases.
func UpdatesApplyAll ¶
UpdatesApplyAll applies all possible database patches. If "doBackup" is true, the sqlite file will be backed up before any update is applied. The legacyPatches parameter is used by the Daemon as a mean to apply the legacy V10, V11, V15, V29 and V30 non-db updates during the database upgrade sequence, to avoid any change in semantics wrt the old logic (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 Architecture int BaseImage string Config map[string]string CreationDate 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 )
type LegacyPatch ¶
type LegacyPatch struct { NeedsDB bool // Whether the patch does any DB-related work Hook func() error // The actual patch logic }
LegacyPatch is a "database" update that performs non-database work. They are needed for historical reasons, since there was a time were db updates could do non-db work and depend on functionality external to the db package. See UpdatesApplyAll below.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package query implements helpers around database/sql to execute various kinds of very common SQL queries.
|
Package query implements helpers around database/sql to execute various kinds of very common SQL queries. |
Package schema offers utilities to create and maintain a database schema.
|
Package schema offers utilities to create and maintain a database schema. |