本文整理汇总了Golang中github.com/containerops/wharf/models.Image.Has方法的典型用法代码示例。如果您正苦于以下问题:Golang Image.Has方法的具体用法?Golang Image.Has怎么用?Golang Image.Has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/containerops/wharf/models.Image
的用法示例。
在下文中一共展示了Image.Has方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetImageLayer
func (this *ImageAPIV1Controller) GetImageLayer() {
imageId := string(this.Ctx.Input.Param(":image_id"))
image := new(models.Image)
if has, _, err := image.Has(imageId); err != nil {
this.JSONOut(http.StatusBadRequest, "Read Image Layer file Error", nil)
return
} else if has == false {
this.JSONOut(http.StatusBadRequest, "Read Image None", nil)
return
}
layerfile := image.Path
if _, err := os.Stat(layerfile); err != nil {
this.JSONOut(http.StatusBadRequest, "Read Image file state error", nil)
return
}
file, err := ioutil.ReadFile(layerfile)
if err != nil {
this.JSONOut(http.StatusBadRequest, "Read Image file error", nil)
return
}
this.Ctx.Output.Context.ResponseWriter.Header().Set("Content-Type", "application/octet-stream")
this.Ctx.Output.Context.ResponseWriter.Header().Set("Content-Transfer-Encoding", "binary")
this.Ctx.Output.Context.ResponseWriter.Header().Set("Content-Length", string(int64(len(file))))
this.Ctx.Output.Context.Output.SetStatus(http.StatusOK)
this.Ctx.Output.Context.Output.Body(file)
return
}
示例2: GetImageAncestry
func (this *ImageAPIV1Controller) GetImageAncestry() {
imageId := string(this.Ctx.Input.Param(":image_id"))
image := new(models.Image)
if has, _, err := image.Has(imageId); err != nil {
this.JSONOut(http.StatusBadRequest, "Read Image Ancestry Error", nil)
return
} else if has == false {
this.JSONOut(http.StatusBadRequest, "Read Image None", nil)
return
}
this.Ctx.Output.Context.Output.SetStatus(http.StatusOK)
this.Ctx.Output.Context.Output.Body([]byte(image.Ancestry))
return
}