本文整理汇总了Golang中github.com/lxc/lxd/shared.ImageInfo.AutoUpdate方法的典型用法代码示例。如果您正苦于以下问题:Golang ImageInfo.AutoUpdate方法的具体用法?Golang ImageInfo.AutoUpdate怎么用?Golang ImageInfo.AutoUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/lxc/lxd/shared.ImageInfo
的用法示例。
在下文中一共展示了ImageInfo.AutoUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ImageDownload
//.........这里部分代码省略.........
if err := json.Unmarshal(resp.Metadata, &info); err != nil {
return "", err
}
/* now grab the actual file from /1.0/images/%s/export */
if secret != "" {
exporturl = fmt.Sprintf(
"%s/%s/images/%s/export?secret=%s",
server, shared.APIVersion, fp, secret)
} else {
exporturl = fmt.Sprintf(
"%s/%s/images/%s/export",
server, shared.APIVersion, fp)
}
} else if protocol == "simplestreams" {
err := ss.Download(fp, "meta", destName, nil)
if err != nil {
return "", err
}
err = ss.Download(fp, "root", destName+".rootfs", progress)
if err != nil {
return "", err
}
info, err := ss.GetImageInfo(fp)
if err != nil {
return "", err
}
info.Public = false
info.AutoUpdate = autoUpdate
_, err = imageBuildFromInfo(d, *info)
if err != nil {
return "", err
}
if alias != fp {
id, _, err := dbImageGet(d.db, fp, false, true)
if err != nil {
return "", err
}
err = dbImageSourceInsert(d.db, id, server, protocol, "", alias)
if err != nil {
return "", err
}
}
if forContainer {
return fp, dbImageLastAccessInit(d.db, fp)
}
return fp, nil
}
raw, err := d.httpGetFile(exporturl, certificate)
if err != nil {
shared.Log.Error(
"Failed to download image",
log.Ctx{"image": fp, "err": err})
return "", err
}
示例2: ImageDownload
//.........这里部分代码省略.........
if err := json.Unmarshal(resp.Metadata, &info); err != nil {
return "", err
}
/* now grab the actual file from /1.0/images/%s/export */
if secret != "" {
exporturl = fmt.Sprintf(
"%s/%s/images/%s/export?secret=%s",
server, shared.APIVersion, fp, secret)
} else {
exporturl = fmt.Sprintf(
"%s/%s/images/%s/export",
server, shared.APIVersion, fp)
}
} else if protocol == "simplestreams" {
err := ss.Download(fp, "meta", destName, nil)
if err != nil {
return "", err
}
err = ss.Download(fp, "root", destName+".rootfs", progress)
if err != nil {
return "", err
}
info, err := ss.GetImageInfo(fp)
if err != nil {
return "", err
}
info.Public = false
info.AutoUpdate = autoUpdate
_, err = imageBuildFromInfo(d, *info)
if err != nil {
return "", err
}
if alias != fp {
id, _, err := dbImageGet(d.db, fp, false, true)
if err != nil {
return "", err
}
err = dbImageSourceInsert(d.db, id, server, protocol, "", alias)
if err != nil {
return "", err
}
}
shared.LogInfo("Image downloaded", ctxMap)
if forContainer {
return fp, dbImageLastAccessInit(d.db, fp)
}
return fp, nil
}
raw, err := d.httpGetFile(exporturl, certificate)
if err != nil {
shared.LogError(
"Failed to download image",
log.Ctx{"image": fp, "err": err})