本文整理匯總了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
}