func (r DirReader) Read() (Release, error) { var release Release // e.g. room101-0+dev.16.yml manifestFileName := r.releaseName + "-" + r.releaseVersion + ".yml" manifestPath := filepath.Join(r.dir, "dev_releases", manifestFileName) 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 }
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 }