本文整理匯總了Golang中github.com/flynn/flynn/controller/types.Artifact.Manifest方法的典型用法代碼示例。如果您正苦於以下問題:Golang Artifact.Manifest方法的具體用法?Golang Artifact.Manifest怎麽用?Golang Artifact.Manifest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/flynn/flynn/controller/types.Artifact
的用法示例。
在下文中一共展示了Artifact.Manifest方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: downloadImage
func (d *Downloader) downloadImage(artifact *ct.Artifact, info chan *ct.ImagePullInfo) error {
info <- &ct.ImagePullInfo{
Name: artifact.Meta["flynn.component"],
Type: ct.ImagePullTypeImage,
Artifact: artifact,
}
for _, rootfs := range artifact.Manifest().Rootfs {
for _, layer := range rootfs.Layers {
if layer.Type != ct.ImageLayerTypeSquashfs {
continue
}
info <- &ct.ImagePullInfo{
Name: artifact.Meta["flynn.component"],
Type: ct.ImagePullTypeLayer,
Layer: layer,
}
if err := d.downloadSquashfsLayer(layer, artifact.LayerURL(layer), artifact.Meta); err != nil {
return fmt.Errorf("error downloading layer: %s", err)
}
}
}
return nil
}
示例2: exportImage
func (e *Exporter) exportImage(name string, artifact *ct.Artifact) error {
log := e.log.New("name", name)
for _, rootfs := range artifact.Manifest().Rootfs {
for _, layer := range rootfs.Layers {
log.Info("exporting layer", "id", layer.ID)
if err := e.exportLayer(layer); err != nil {
log.Error("error exporting layer", "id", layer.ID, "err", err)
return err
}
}
}
path := e.imagePath(artifact.Manifest().ID())
if _, err := os.Stat(path); err == nil {
log.Info("manifest already exists")
return nil
}
log.Info("writing image manifest", "path", path)
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
log.Error("error writing image manifest", "path", path, "err", err)
return err
}
if err := ioutil.WriteFile(path, artifact.RawManifest, 0644); err != nil {
log.Error("error writing image manifest", "path", path, "err", err)
return err
}
return nil
}
示例3: deployApp
func deployApp(client controller.Client, app *ct.App, image *ct.Artifact, updateFn updater.UpdateReleaseFn, log log15.Logger) error {
release, err := client.GetAppRelease(app.ID)
if err != nil {
log.Error("error getting release", "err", err)
return err
}
if len(release.ArtifactIDs) == 0 {
return errDeploySkipped{"release has no artifacts"}
}
artifact, err := client.GetArtifact(release.ArtifactIDs[0])
if err != nil {
log.Error("error getting release artifact", "err", err)
return err
}
if !app.System() && release.IsGitDeploy() {
if artifact.Meta["flynn.component"] != "slugrunner" {
return errDeploySkipped{"app not using slugrunner image"}
}
}
skipDeploy := artifact.Manifest().ID() == image.Manifest().ID()
if updateImageIDs(release.Env) {
skipDeploy = false
}
if skipDeploy {
return errDeploySkipped{"app is already using latest images"}
}
if err := client.CreateArtifact(image); err != nil {
log.Error("error creating artifact", "err", err)
return err
}
release.ID = ""
release.ArtifactIDs[0] = image.ID
if updateFn != nil {
updateFn(release)
}
if err := client.CreateRelease(release); err != nil {
log.Error("error creating new release", "err", err)
return err
}
timeoutCh := make(chan struct{})
time.AfterFunc(deployTimeout, func() { close(timeoutCh) })
if err := client.DeployAppRelease(app.ID, release.ID, timeoutCh); err != nil {
log.Error("error deploying app", "err", err)
return err
}
return nil
}