本文整理汇总了Golang中github.com/containerops/dockyard/models.Repository.GetTagslist方法的典型用法代码示例。如果您正苦于以下问题:Golang Repository.GetTagslist方法的具体用法?Golang Repository.GetTagslist怎么用?Golang Repository.GetTagslist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/containerops/dockyard/models.Repository
的用法示例。
在下文中一共展示了Repository.GetTagslist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetTagV1Handler
func GetTagV1Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
namespace := ctx.Params(":namespace")
repository := ctx.Params(":repository")
r := new(models.Repository)
if exists, err := r.Get(namespace, repository); err != nil {
log.Error("[REGISTRY API V1] Failed to get repository %v/%v context: %v", namespace, repository, err.Error())
result, _ := json.Marshal(map[string]string{"message": "Failed to get repository context"})
return http.StatusBadRequest, result
} else if exists == false {
log.Error("[REGISTRY API V1] Not found repository %v/%v", namespace, repository)
result, _ := json.Marshal(map[string]string{"message": "Not found repository"})
return http.StatusNotFound, result
}
tags := map[string]string{}
tagslist := r.GetTagslist()
for _, tagname := range tagslist {
t := new(models.Tag)
if exists, err := t.Get(namespace, repository, tagname); err != nil || !exists {
log.Error(fmt.Sprintf("[REGISTRY API V1] %s/%s %v is not exist", namespace, repository, tagname))
result, _ := json.Marshal(map[string]string{"message": "Tag is not exist"})
return http.StatusNotFound, result
}
tags[tagname] = t.ImageId
}
result, _ := json.Marshal(tags)
return http.StatusOK, result
}
示例2: GetTagsListV2Handler
func GetTagsListV2Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
namespace := ctx.Params(":namespace")
repository := ctx.Params(":repository")
r := new(models.Repository)
if _, err := r.Get(namespace, repository); err != nil {
log.Error("[REGISTRY API V2] Failed to get repository %v/%v: %v", namespace, repository, err.Error())
result, _ := json.Marshal(map[string]string{"message": "Failed to get repository"})
return http.StatusBadRequest, result
}
data := map[string]interface{}{}
data["name"] = fmt.Sprintf("%s/%s", namespace, repository)
tagslist := r.GetTagslist()
if len(tagslist) <= 0 {
log.Error("[REGISTRY API V2] Repository %v/%v tags list is empty", namespace, repository)
result, _ := json.Marshal(map[string]string{"message": "Tags list is empty"})
return http.StatusNotFound, result
}
data["tags"] = tagslist
result, _ := json.Marshal(data)
return http.StatusOK, result
}