Пример #1
0
func NewIncompleteRelease(relVerRec bhrelsrepo.ReleaseVersionRec, name string) Release {
	return Release{
		relVerRec: relVerRec,

		Source: NewSource(relVerRec.AsSource()),

		Name:    name,
		Version: relVerRec.Version(),
	}
}
Пример #2
0
func NewRelease(relVerRec bhrelsrepo.ReleaseVersionRec, r bprel.Release) Release {
	rel := Release{
		relVerRec: relVerRec,

		Source: NewSource(relVerRec.AsSource()),

		Name:    r.Name,
		Version: relVerRec.Version(),

		CommitHash: r.CommitHash,

		IsLatest: false,
	}

	rel.Jobs = NewJobs(r.Jobs, rel)
	rel.Packages = NewPackages(r.Packages, rel)

	return rel
}
// Show uses '_1' param as release source and 'v' param as release version
func (c ReleaseTarballsController) Download(req *http.Request, r martrend.Render, params mart.Params) {
	relSource := params["_1"]

	if len(relSource) == 0 {
		err := bosherr.New("Param 'source' must be non-empty")
		r.HTML(400, c.errorTmpl, err)
		return
	}

	relVersion := req.URL.Query().Get("v")

	var relVerRec bhrelsrepo.ReleaseVersionRec
	var err error

	if relVersion == "" {
		relVerRec, err = c.releasesRepo.FindLatest(relSource)
		if err != nil {
			r.HTML(500, c.errorTmpl, err)
			return
		}
	} else {
		relVerRec, err = c.releasesRepo.Find(relSource, relVersion)
		if err != nil {
			r.HTML(500, c.errorTmpl, err)
			return
		}
	}

	relTarRec, err := relVerRec.Tarball()
	if err != nil {
		r.HTML(500, c.errorTmpl, err)
		return
	}

	url, err := relTarRec.ActualDownloadURL()
	if err != nil {
		r.HTML(500, c.errorTmpl, err)
		return
	}

	r.Redirect(url)
}
Пример #4
0
func (u Uploader) Upload(relVerRec bhrelsrepo.ReleaseVersionRec, tgzPath string) error {
	u.logger.Info(u.logTag, "Uploading '%s' for '%v'", tgzPath, relVerRec)

	blobID, sha, err := u.blobstore.Create(tgzPath)
	if err != nil {
		return bosherr.WrapError(err, "Creating release tarball")
	}

	relTarRec := bhreltarsrepo.ReleaseTarballRec{
		BlobID: blobID,
		SHA1:   sha,
	}

	err = relVerRec.SetTarball(relTarRec)
	if err != nil {
		return bosherr.WrapError(err, "Saving release into release tarballs repository")
	}

	return nil
}