//PutManifestsV2Handler is func PutManifestsV2Handler(ctx *macaron.Context) (int, []byte) { repository := ctx.Params(":repository") namespace := ctx.Params(":namespace") agent := ctx.Req.Header.Get("User-Agent") tag := ctx.Params(":tag") if data, err := ctx.Req.Body().String(); err != nil { log.Errorf("Get the manifest data error: %s", err.Error()) result, _ := json.Marshal(map[string]string{}) return http.StatusBadRequest, result } else { _, imageID, version, _ := module.GetTarsumlist([]byte(data)) digest, _ := signature.DigestManifest([]byte(data)) r := new(models.DockerV2) if err := r.PutAgent(namespace, repository, agent, strconv.FormatInt(version, 10)); err != nil { log.Errorf("Put the manifest data error: %s", err.Error()) result, _ := json.Marshal(map[string]string{}) return http.StatusBadRequest, result } t := new(models.DockerTagV2) if err := t.Put(namespace, repository, tag, imageID, data, strconv.FormatInt(version, 10)); err != nil { log.Errorf("Put the manifest data error: %s", err.Error()) result, _ := json.Marshal(map[string]string{}) return http.StatusBadRequest, result } random := fmt.Sprintf("https://%s/v2/%s/%s/manifests/%s", setting.Domains, namespace, repository, digest) ctx.Resp.Header().Set("Content-Type", "text/plain; charset=utf-8") ctx.Resp.Header().Set("Docker-Content-Digest", digest) ctx.Resp.Header().Set("Location", random) status := []int{http.StatusBadRequest, http.StatusAccepted, http.StatusCreated} result, _ := json.Marshal(map[string]string{}) return status[version], result } }