Esempio n. 1
0
func (this *RepoAPIV1Controller) GetRepositoryTags() {
	namespace := this.Ctx.Input.Param(":namespace")
	repository := this.Ctx.Input.Param(":repo_name")

	repo := new(models.Repository)

	if has, _, err := repo.Has(namespace, repository); err != nil {
		this.JSONOut(http.StatusBadRequest, "Read repository json error", nil)
		return
	} else if has == false {
		this.JSONOut(http.StatusBadRequest, "Read repository no found", nil)
		return
	}

	tag := map[string]string{}

	for _, value := range repo.Tags {
		t := new(models.Tag)
		if err := t.GetById(value); err != nil {
			this.JSONOut(http.StatusBadRequest, "", map[string]string{"message": fmt.Sprintf("%s/%s Tags is not exist", namespace, repository)})
			return
		}

		tag[t.Name] = t.ImageId
	}

	this.JSONOut(http.StatusOK, "", tag)
	return
}
Esempio n. 2
0
func (this *ManifestsAPIV2Controller) GetTags() {
	namespace := this.Ctx.Input.Param(":namespace")
	repository := this.Ctx.Input.Param(":repo_name")

	repo := new(models.Repository)

	if has, _, err := repo.Has(namespace, repository); err != nil || has == false {
		this.JSONOut(http.StatusBadRequest, "", map[string][]modules.ErrorDescriptor{"errors": []modules.ErrorDescriptor{modules.ErrorDescriptors[modules.APIErrorCodeNameInvalid]}})
		return
	}

	data := map[string]interface{}{}
	tags := []string{}

	data["name"] = fmt.Sprintf("%s/%s", namespace, repository)

	for _, value := range repo.Tags {
		t := new(models.Tag)
		if err := t.GetById(value); err != nil {
			this.JSONOut(http.StatusBadRequest, "", map[string][]modules.ErrorDescriptor{"errors": []modules.ErrorDescriptor{modules.ErrorDescriptors[modules.APIErrorCodeTagInvalid]}})
			return
		}

		tags = append(tags, t.Name)
	}

	data["tags"] = tags

	this.JSONOut(http.StatusOK, "", data)
	return
}
Esempio n. 3
0
func (this *ManifestsAPIV2Controller) GetManifests() {
	namespace := this.Ctx.Input.Param(":namespace")
	repository := this.Ctx.Input.Param(":repo_name")
	tag := this.Ctx.Input.Param(":tag")

	t := new(models.Tag)
	if err := t.GetById(fmt.Sprintf("%s:%s:%s", namespace, repository, tag)); err != nil {
		this.JSONOut(http.StatusBadRequest, "", map[string][]modules.ErrorDescriptor{"errors": []modules.ErrorDescriptor{modules.ErrorDescriptors[modules.APIErrorCodeTagInvalid]}})
		return
	}

	this.Ctx.Output.Context.Output.SetStatus(http.StatusOK)
	this.Ctx.Output.Context.Output.Body([]byte(t.Manifest))
	return
}