本文整理汇总了Golang中github.com/lxc/lxd/shared.ImageInfo.Source方法的典型用法代码示例。如果您正苦于以下问题:Golang ImageInfo.Source方法的具体用法?Golang ImageInfo.Source怎么用?Golang ImageInfo.Source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/lxc/lxd/shared.ImageInfo
的用法示例。
在下文中一共展示了ImageInfo.Source方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: dbImageGet
//.........这里部分代码省略.........
var inargs []interface{}
if strictMatching {
inargs = []interface{}{fingerprint}
query = `
SELECT
id, fingerprint, filename, size, cached, public, auto_update, architecture,
creation_date, expiry_date, last_use_date, upload_date
FROM
images
WHERE fingerprint = ?`
} else {
inargs = []interface{}{fingerprint + "%"}
query = `
SELECT
id, fingerprint, filename, size, cached, public, auto_update, architecture,
creation_date, expiry_date, last_use_date, upload_date
FROM
images
WHERE fingerprint LIKE ?`
}
if public {
query = query + " AND public=1"
}
err = dbQueryRowScan(db, query, inargs, outfmt)
if err != nil {
return -1, nil, err // Likely: there are no rows for this fingerprint
}
// Some of the dates can be nil in the DB, let's process them.
if create != nil {
image.CreationDate = *create
} else {
image.CreationDate = time.Time{}
}
if expire != nil {
image.ExpiryDate = *expire
} else {
image.ExpiryDate = time.Time{}
}
if used != nil {
image.LastUsedDate = *used
} else {
image.LastUsedDate = time.Time{}
}
image.Architecture, _ = shared.ArchitectureName(arch)
// The upload date is enforced by NOT NULL in the schema, so it can never be nil.
image.UploadDate = *upload
// Get the properties
q := "SELECT key, value FROM images_properties where image_id=?"
var key, value, name, desc string
inargs = []interface{}{id}
outfmt = []interface{}{key, value}
results, err := dbQueryScan(db, q, inargs, outfmt)
if err != nil {
return -1, nil, err
}
properties := map[string]string{}
for _, r := range results {
key = r[0].(string)
value = r[1].(string)
properties[key] = value
}
image.Properties = properties
// Get the aliases
q = "SELECT name, description FROM images_aliases WHERE image_id=?"
inargs = []interface{}{id}
outfmt = []interface{}{name, desc}
results, err = dbQueryScan(db, q, inargs, outfmt)
if err != nil {
return -1, nil, err
}
aliases := []shared.ImageAlias{}
for _, r := range results {
name = r[0].(string)
desc = r[0].(string)
a := shared.ImageAlias{Name: name, Description: desc}
aliases = append(aliases, a)
}
image.Aliases = aliases
_, source, err := dbImageSourceGet(db, id)
if err == nil {
image.Source = &source
}
return id, &image, nil
}