Ejemplo n.º 1
0
func (r *TarReader) Read() (Release, error) {
	var release Release

	downloadPath, err := r.downloader.Download(r.url)
	if err != nil {
		return release, bosherr.WrapError(err, "Downloading release")
	}

	r.downloadPath = downloadPath

	extractPath, err := r.extractor.Extract(r.downloadPath)
	if err != nil {
		cleanUpErr := r.downloader.CleanUp(r.downloadPath)
		if cleanUpErr != nil {
			r.logger.Debug(tarReaderLogTag,
				"Failed to clean up downloaded release %v", cleanUpErr)
		}

		return release, bosherr.WrapError(err, "Extracting release")
	}

	r.extractPath = extractPath

	manifestPath := filepath.Join(r.extractPath, "release.MF")

	manifest, err := bprelman.NewManifestFromPath(manifestPath, r.fs)
	if err != nil {
		closeErr := r.Close()
		if closeErr != nil {
			r.logger.Debug(tarReaderLogTag,
				"Failed to close release %v", closeErr)
		}

		return release, bosherr.WrapError(err, "Building manifest")
	}

	r.logger.Debug(tarReaderLogTag, "Done building manifest %#v", manifest)

	release.populateFromManifest(manifest)

	r.populateReleaseTarPaths(&release)

	return release, nil
}
Ejemplo n.º 2
0
func (r DirReader) Read() (Release, error) {
	var release Release

	// e.g. room101-0+dev.16.yml
	manifestFileName := r.releaseName + "-" + r.releaseVersion + ".yml"

	// bosh_cli now places release manifests into sub-directories named after a release
	oldManifestPath := filepath.Join(r.dir, "dev_releases", manifestFileName)
	migratedManifestPath := filepath.Join(r.dir, "dev_releases", r.releaseName, manifestFileName)

	manifestPath := r.pathThatExistsOrEmpty(oldManifestPath, migratedManifestPath)
	if len(manifestPath) == 0 {
		return release, bosherr.New(
			"Manifest not found at '%s' or '%s'",
			oldManifestPath,
			migratedManifestPath,
		)
	}

	manifest, err := bprelman.NewManifestFromPath(manifestPath, r.fs)
	if err != nil {
		closeErr := r.Close()
		if closeErr != nil {
			r.logger.Debug(dirReaderLogTag, "Failed to close release %v", closeErr)
		}

		return release, bosherr.WrapError(err, "Building manifest")
	}

	r.logger.Debug(dirReaderLogTag, "Done building manifest %#v", manifest)

	release.populateFromManifest(manifest)

	r.populateReleaseTarPaths(&release)

	return release, nil
}