本文整理匯總了Golang中github.com/coreos/rkt/store.Store.GetACI方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.GetACI方法的具體用法?Golang Store.GetACI怎麽用?Golang Store.GetACI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coreos/rkt/store.Store
的用法示例。
在下文中一共展示了Store.GetACI方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getStoreKeyFromApp
func getStoreKeyFromApp(s *store.Store, img string) (string, error) {
app, err := discovery.NewAppFromString(img)
if err != nil {
return "", fmt.Errorf("cannot parse the image name: %v", err)
}
labels, err := types.LabelsFromMap(app.Labels)
if err != nil {
return "", fmt.Errorf("invalid labels in the name: %v", err)
}
key, err := s.GetACI(app.Name, labels)
if err != nil {
return "", fmt.Errorf("cannot find image: %v", err)
}
return key, nil
}
示例2: getStoreKeyFromApp
func getStoreKeyFromApp(s *store.Store, img string) (string, error) {
app, err := discovery.NewAppFromString(img)
if err != nil {
return "", fmt.Errorf("cannot parse the image name %q: %v", img, err)
}
labels, err := types.LabelsFromMap(app.Labels)
if err != nil {
return "", fmt.Errorf("invalid labels in the image %q: %v", img, err)
}
key, err := s.GetACI(app.Name, labels)
if err != nil {
switch err.(type) {
case store.ACINotFoundError:
return "", err
default:
return "", fmt.Errorf("cannot find image %q: %v", img, err)
}
}
return key, nil
}
示例3: getKeyFromAppOrHash
func getKeyFromAppOrHash(s *store.Store, input string) (string, error) {
var key string
if _, err := types.NewHash(input); err == nil {
key, err = s.ResolveKey(input)
if err != nil {
return "", fmt.Errorf("cannot resolve key: %v", err)
}
} else {
app, err := discovery.NewAppFromString(input)
if err != nil {
return "", fmt.Errorf("cannot parse the image name: %v", err)
}
labels, err := types.LabelsFromMap(app.Labels)
if err != nil {
return "", fmt.Errorf("invalid labels in the name: %v", err)
}
key, err = s.GetACI(app.Name, labels)
if err != nil {
return "", fmt.Errorf("cannot find image: %v", err)
}
}
return key, nil
}