// Given an image app name and optional labels, get the best matching image // available in the store, build its dependency list and render it inside dir func RenderACI(name types.ACIdentifier, labels types.Labels, dir string, ap acirenderer.ACIRegistry, uidRange *user.UidRange) error { renderedACI, err := acirenderer.GetRenderedACI(name, labels, ap) if err != nil { return err } return renderImage(renderedACI, dir, ap, uidRange) }
// FetchAndRender will fetch the given image and all of its dependencies if // they have not been fetched yet, and will then render them on to the // filesystem if they have not been rendered yet. func (r Registry) FetchAndRender(imagename types.ACIdentifier, labels types.Labels, size uint) error { err := r.Fetch(imagename, labels, size, true) if err != nil { return err } filesToRender, err := acirenderer.GetRenderedACI(imagename, labels, r) if err != nil { return err } filesloop: for _, fs := range filesToRender { _, err := os.Stat(path.Join(r.DepStoreExpandedPath, fs.Key, "rendered")) switch { case os.IsNotExist(err): break case err != nil: return err default: // This ACI has already been rendered continue filesloop } err = util.ExtractImage(path.Join(r.DepStoreTarPath, fs.Key), path.Join(r.DepStoreExpandedPath, fs.Key), fs.FileMap) if err != nil { return err } rfile, err := os.Create( path.Join(r.DepStoreExpandedPath, fs.Key, "rendered")) if err != nil { return err } rfile.Close() } return nil }