本文整理汇总了Golang中github.com/coreos/rkt/store/imagestore.Store.GetACIInfoWithBlobKey方法的典型用法代码示例。如果您正苦于以下问题:Golang Store.GetACIInfoWithBlobKey方法的具体用法?Golang Store.GetACIInfoWithBlobKey怎么用?Golang Store.GetACIInfoWithBlobKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/rkt/store/imagestore.Store
的用法示例。
在下文中一共展示了Store.GetACIInfoWithBlobKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: rmImages
func rmImages(s *imagestore.Store, images []string) error {
imageMap := make(map[string]string)
for _, img := range images {
key, err := getStoreKeyFromAppOrHash(s, img)
if err != nil {
stderr.Error(err)
continue
}
aciinfo, err := s.GetACIInfoWithBlobKey(key)
if err != nil {
stderr.PrintE(fmt.Sprintf("error retrieving aci infos for image %q", key), err)
continue
}
imageMap[key] = aciinfo.Name
}
done := 0
errors := 0
staleErrors := 0
for key, name := range imageMap {
if err := s.RemoveACI(key); err != nil {
if serr, ok := err.(*imagestore.StoreRemovalError); ok {
staleErrors++
stderr.PrintE(fmt.Sprintf("some files cannot be removed for image %q (%q)", key, name), serr)
} else {
errors++
stderr.PrintE(fmt.Sprintf("error removing aci for image %q (%q)", key, name), err)
continue
}
}
stdout.Printf("successfully removed aci for image: %q", key)
done++
}
if done > 0 {
stderr.Printf("%d image(s) successfully removed", done)
}
// If anything didn't complete, return exit status of 1
if (errors + staleErrors) > 0 {
if staleErrors > 0 {
stderr.Printf("%d image(s) removed but left some stale files", staleErrors)
}
if errors > 0 {
stderr.Printf("%d image(s) cannot be removed", errors)
}
return fmt.Errorf("error(s) found while removing images")
}
return nil
}
示例2: getImageInfoFromDisk
// getImageInfoFromDisk for a given image ID, returns the *v1alpha.Image object.
func (s *v1AlphaAPIServer) getImageInfoFromDisk(store *imagestore.Store, imageID string) (*v1alpha.Image, error) {
aciInfo, err := store.GetACIInfoWithBlobKey(imageID)
if err != nil {
stderr.PrintE(fmt.Sprintf("failed to get ACI info for image %q", imageID), err)
return nil, err
}
image, err := aciInfoToV1AlphaAPIImage(store, aciInfo)
if err != nil {
stderr.PrintE(fmt.Sprintf("failed to convert ACI to v1alphaAPIImage for image %q", imageID), err)
return nil, err
}
return image, nil
}
示例3: rmImages
func rmImages(s *imagestore.Store, images []string) error {
done := 0
errors := 0
staleErrors := 0
imageMap := make(map[string]string)
imageCounter := make(map[string]int)
for _, pkey := range images {
errors++
h, err := types.NewHash(pkey)
if err != nil {
var found bool
keys, found, err := s.ResolveName(pkey)
if len(keys) > 0 {
errors += len(keys) - 1
}
if err != nil {
stderr.Error(err)
continue
}
if !found {
stderr.Printf("image name %q not found", pkey)
continue
}
for _, key := range keys {
imageMap[key] = pkey
imageCounter[key]++
}
} else {
key, err := s.ResolveKey(h.String())
if err != nil {
stderr.PrintE(fmt.Sprintf("image ID %q not valid", pkey), err)
continue
}
if key == "" {
stderr.Printf("image ID %q doesn't exist", pkey)
continue
}
aciinfo, err := s.GetACIInfoWithBlobKey(key)
if err != nil {
stderr.PrintE(fmt.Sprintf("error retrieving aci infos for image %q", key), err)
continue
}
imageMap[key] = aciinfo.Name
imageCounter[key]++
}
}
// Adjust the error count by subtracting duplicate IDs from it,
// therefore allowing only one error per ID.
for _, c := range imageCounter {
if c > 1 {
errors -= c - 1
}
}
for key, name := range imageMap {
if err := s.RemoveACI(key); err != nil {
if serr, ok := err.(*imagestore.StoreRemovalError); ok {
staleErrors++
stderr.PrintE(fmt.Sprintf("some files cannot be removed for image %q (%q)", key, name), serr)
} else {
stderr.PrintE(fmt.Sprintf("error removing aci for image %q (%q)", key, name), err)
continue
}
}
stdout.Printf("successfully removed aci for image: %q", key)
errors--
done++
}
if done > 0 {
stderr.Printf("%d image(s) successfully removed", done)
}
// If anything didn't complete, return exit status of 1
if (errors + staleErrors) > 0 {
if staleErrors > 0 {
stderr.Printf("%d image(s) removed but left some stale files", staleErrors)
}
if errors > 0 {
stderr.Printf("%d image(s) cannot be removed", errors)
}
return fmt.Errorf("error(s) found while removing images")
}
return nil
}