本文整理汇总了Golang中github.com/coreos/rkt/store.Store.WriteACI方法的典型用法代码示例。如果您正苦于以下问题:Golang Store.WriteACI方法的具体用法?Golang Store.WriteACI怎么用?Golang Store.WriteACI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/rkt/store.Store
的用法示例。
在下文中一共展示了Store.WriteACI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExtractLayerInfo
// ExtractLayerInfo extracts the image name and ID from a path to an ACI
func ExtractLayerInfo(store *store.Store, in string) (types.Dependency, error) {
im, err := GetManifestFromImage(in)
if err != nil {
return types.Dependency{}, fmt.Errorf("error getting manifest from image (%v): %v", in, err)
}
inFile, err := os.Open(in)
if err != nil {
return types.Dependency{}, fmt.Errorf("error opening ACI: %v", err)
}
defer inFile.Close()
inImageID, err := store.WriteACI(inFile, false)
if err != nil {
return types.Dependency{}, fmt.Errorf("error writing ACI into the tree store: %v", err)
}
hash, err := types.NewHash(inImageID)
if err != nil {
return types.Dependency{}, fmt.Errorf("error creating hash from an image ID (%s): %v", hash, err)
}
return types.Dependency{
ImageName: im.Name,
ImageID: hash,
}, nil
}
示例2: renderInStore
// renderInStore renders a ACI specified by `filename` in the given tree store,
// and returns the hash (image ID) of the rendered ACI.
func renderInStore(s *store.Store, filename string) (string, error) {
// Put the ACI into the store
f, err := os.Open(filename)
if err != nil {
return "", fmt.Errorf("Could not open ACI image: %s", err)
}
key, err := s.WriteACI(f, false)
if err != nil {
return "", fmt.Errorf("Could not open ACI: %s", key)
}
// Render the ACI
if err := s.RenderTreeStore(key, false); err != nil {
return "", fmt.Errorf("Could not render tree store: %s", err)
}
return key, err
}