Skip to content

Commit

Permalink
Merge pull request #608 from cloudfoundry/bugfix/idempotent-prefix-ve…
Browse files Browse the repository at this point in the history
…ndored-package-#184440093

fix inconsistent vendor package behaviour
  • Loading branch information
rkoster authored Feb 15, 2023
2 parents 6c8f15f + be78cc3 commit c39f9de
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion releasedir/fs_release_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,10 @@ func (d FSReleaseDir) VendorPackage(pkg *boshpkg.Package, prefix string) error {
if err != nil {
return bosherr.WrapErrorf(err, "Finalizing vendored package")
}
}

err = d.writeVendoredPackage(pkg2)
for pkg2 := range allInterestingPkgs {
err := d.writeVendoredPackage(pkg2)
if err != nil {
return bosherr.WrapErrorf(err, "Writing vendored package")
}
Expand Down
26 changes: 26 additions & 0 deletions releasedir/fs_release_dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,32 @@ fingerprint: pkg4-fp
Expect(pkg4Res.FinalizeArgsForCall(0) == finalIndicies.Packages).To(BeTrue())
})

It("reliably vendors packages with prefix inlcuding their dependencies", func() {
_, err := fs.ReadFileString("/dir/packages/prefixed-pkg1-name/spec.lock")

Expect(err).To(HaveOccurred())
pkg2Res := resource.NewResourceWithBuiltArchive("pkg2-name", "pkg2-fp", "/test/something", "something")
pkg3Res := resource.NewResourceWithBuiltArchive("pkg3-name", "pkg3-fp", "/test/something", "something")
pkg2 := boshpkg.NewPackage(pkg2Res, []string{})
pkg3 := boshpkg.NewPackage(pkg3Res, []string{})

pkg1Res := resource.NewResourceWithBuiltArchive("pkg1-name", "pkg1-fp", "/test/something", "something")
pkg1 := boshpkg.NewPackage(pkg1Res, []string{"pkg2-name", "pkg3-name"})

err = pkg1.AttachDependencies([]*boshpkg.Package{pkg2, pkg3})
Expect(err).ToNot(HaveOccurred())

err = releaseDir.VendorPackage(pkg1, "prefixed")
Expect(err).ToNot(HaveOccurred())

Expect(fs.ReadFileString("/dir/packages/prefixed-pkg1-name/spec.lock")).To(Equal(`name: prefixed-pkg1-name
fingerprint: pkg1-fp
dependencies:
- prefixed-pkg2-name
- prefixed-pkg3-name
`))
})

It("finalize given package with prefix", func() {
pkg1Res := resource.NewResourceWithBuiltArchive("pkg1-name", "pkg1-fp", "/test/something", "something")
pkg1 := boshpkg.NewPackage(pkg1Res, nil)
Expand Down

0 comments on commit c39f9de

Please sign in to comment.