本文整理汇总了Golang中github.com/containerops/wharf/models.Image.PutChecksum方法的典型用法代码示例。如果您正苦于以下问题:Golang Image.PutChecksum方法的具体用法?Golang Image.PutChecksum怎么用?Golang Image.PutChecksum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/containerops/wharf/models.Image
的用法示例。
在下文中一共展示了Image.PutChecksum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PutChecksum
func (this *ImageAPIV1Controller) PutChecksum() {
imageId := string(this.Ctx.Input.Param(":image_id"))
image := new(models.Image)
checksum := strings.Split(this.Ctx.Input.Header("X-Docker-Checksum"), ":")[1]
payload := strings.Split(this.Ctx.Input.Header("X-Docker-Checksum-Payload"), ":")[1]
if err := image.PutChecksum(imageId, checksum, true, payload); err != nil {
this.JSONOut(http.StatusBadRequest, "Put Image Checksum & Payload Error", nil)
return
}
if err := image.PutAncestry(imageId); err != nil {
this.JSONOut(http.StatusBadRequest, "Put Image Ancestry Error", nil)
return
}
memo, _ := json.Marshal(this.Ctx.Input.Header)
image.Log(models.ACTION_PUT_IMAGES_CHECKSUM, models.LEVELINFORMATIONAL, models.TYPE_APIV1, image.Id, memo)
this.Ctx.Output.Context.Output.SetStatus(http.StatusOK)
this.Ctx.Output.Context.Output.Body([]byte(""))
return
}
示例2: manifestsConvertV1
func manifestsConvertV1(data []byte) error {
var manifest map[string]interface{}
if err := json.Unmarshal(data, &manifest); err != nil {
return err
}
tag := manifest["tag"]
namespace, repository := strings.Split(manifest["name"].(string), "/")[0], strings.Split(manifest["name"].(string), "/")[1]
for k := len(manifest["history"].([]interface{})) - 1; k >= 0; k-- {
v := manifest["history"].([]interface{})[k]
compatibility := v.(map[string]interface{})["v1Compatibility"].(string)
var image map[string]interface{}
if err := json.Unmarshal([]byte(compatibility), &image); err != nil {
return err
}
i := map[string]string{}
r := new(models.Repository)
if k == 0 {
i["Tag"] = tag.(string)
}
i["id"] = image["id"].(string)
//Put V1 JSON
if err := r.PutJSONFromManifests(i, namespace, repository); err != nil {
return err
}
if k == 0 {
//Put V1 Tag
if err := r.PutTagFromManifests(image["id"].(string), namespace, repository, tag.(string), string(data)); err != nil {
return err
}
}
img := new(models.Image)
tarsum := manifest["fsLayers"].([]interface{})[k].(map[string]interface{})["blobSum"].(string)
sha256 := strings.Split(tarsum, ":")[1]
//Put Image Json
if err := img.PutJSON(image["id"].(string), v.(map[string]interface{})["v1Compatibility"].(string), models.APIVERSION_V2); err != nil {
return err
}
//Put Image Layer
basePath := beego.AppConfig.String("docker::BasePath")
layerfile := fmt.Sprintf("%v/uuid/%v/layer", basePath, sha256)
if err := img.PutLayer(image["id"].(string), layerfile, true, int64(image["Size"].(float64))); err != nil {
return err
}
//Put Checksum
if err := img.PutChecksum(image["id"].(string), sha256, true, ""); err != nil {
return err
}
//Put Ancestry
if err := img.PutAncestry(image["id"].(string)); err != nil {
return err
}
}
return nil
}