Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/inspect_local_release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var _ = Describe("InspectLocalReleaseCmd", func() {
compiledPkg := boshpkg.NewCompiledPackageWithoutArchive(
"compiled-pkg-name",
"compiled-pkg-fp",
"",
"my-fancy-linux/1.33.7",
"compiled-pkg-digest",
[]string{"some-package"},
Expand Down
3 changes: 2 additions & 1 deletion cmd/redigest_release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var _ = Describe("RedigestRelease", func() {
}
jobSha128 := boshjob.NewJob(NewResourceWithBuiltArchive("job-resource-1", "job-sha128-fp", job1ResourcePath, fileContentSha1))
packageSha128 := boshpkg.NewPackage(NewResourceWithBuiltArchive("pkg-resource-1", "pkg-sha128-fp", pkg1ResourcePath, fileContentSha1), nil)
compiledPackageSha128 := boshpkg.NewCompiledPackageWithArchive("compiledpkg-resource-1", "compiledpkg-sha128-fp", "1", compiledPackage1ResourcePath, fileContentSha1, nil)
compiledPackageSha128 := boshpkg.NewCompiledPackageWithArchive("compiledpkg-resource-1", "compiledpkg-sha128-fp", "original-compiledpkg-fp", "1", compiledPackage1ResourcePath, fileContentSha1, nil)

fakeSha128Release.JobsReturns([]*boshjob.Job{jobSha128})
fakeSha128Release.PackagesReturns([]*boshpkg.Package{packageSha128})
Expand Down Expand Up @@ -137,6 +137,7 @@ var _ = Describe("RedigestRelease", func() {

Expect(sha2ifyRelease.CompiledPackages()).To(HaveLen(1))
Expect(sha2ifyRelease.CompiledPackages()[0].ArchiveDigest()).To(Equal("sha256:compiledpkgsha256"))
Expect(sha2ifyRelease.CompiledPackages()[0].OriginalFingerprint()).To(Equal("original-compiledpkg-fp"))

Expect(fmv.MoveCallCount()).To(Equal(1))

Expand Down
4 changes: 2 additions & 2 deletions cmd/release_tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ var _ = Describe("ReleaseTables", func() {
Context("when there are compiled packages", func() {
BeforeEach(func() {
compiledpkg := boshpkg.NewCompiledPackageWithoutArchive(
"compiledpkg-name", "compiledpkg-fp", "super-cool-linux/42.0", "compiledpkg-sha1", []string{"pkg1-name"},
"compiledpkg-name", "compiledpkg-fp", "", "super-cool-linux/42.0", "compiledpkg-sha1", []string{"pkg1-name"},
)

compiledpkg2 := boshpkg.NewCompiledPackageWithoutArchive(
"compiledpkg2-name", "compiledpkg2-fp", "super-cool-linux", "compiledpkg2-sha1", []string{"pkg1-name"},
"compiledpkg2-name", "compiledpkg2-fp", "", "super-cool-linux", "compiledpkg2-sha1", []string{"pkg1-name"},
)

release.CompiledPackagesReturns([]*boshpkg.CompiledPackage{compiledpkg, compiledpkg2})
Expand Down
4 changes: 2 additions & 2 deletions deployment/instance/state/remote_package_compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ var _ = Describe("RemotePackageCompiler", func() {

BeforeEach(func() {
pkgDependency = boshpkg.NewCompiledPackageWithoutArchive(
"fake-package-name-dep", "fake-package-fingerprint-dep", "", "", nil)
"fake-package-name-dep", "fake-package-fingerprint-dep", "", "", "", nil)

pkg = boshpkg.NewCompiledPackageWithArchive(
"fake-package-name", "fake-package-fingerprint", "", archivePath, "fake-source-package-sha1", []string{"fake-package-name-dep"})
"fake-package-name", "fake-package-fingerprint", "", "", archivePath, "fake-source-package-sha1", []string{"fake-package-name-dep"})
err := pkg.AttachDependencies([]*boshpkg.CompiledPackage{pkgDependency})
Expect(err).ToNot(HaveOccurred())
})
Expand Down
3 changes: 3 additions & 0 deletions installation/pkg/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ var _ = Describe("PackageCompiler", func() {
compiledPkg = birelpkg.NewCompiledPackageWithArchive(
"compiled-pkg1-name",
"compiled-pkg1-fingerprint",
"",
"compiled-pkg1-os-version-slug",
"compiled-pkg1-path",
"compiled-pkg1-sha1",
Expand All @@ -371,6 +372,7 @@ var _ = Describe("PackageCompiler", func() {
dependency1 = birelpkg.NewCompiledPackageWithArchive(
"compiled-pkg1-dep1-name",
"compiled-pkg1-dep1-fingerprint",
"",
"compiled-pkg1-dep1-os-version-slug",
"compiled-pkg1-dep1-path",
"compiled-pkg1-dep1-sha1",
Expand All @@ -379,6 +381,7 @@ var _ = Describe("PackageCompiler", func() {
dependency2 = birelpkg.NewCompiledPackageWithArchive(
"compiled-pkg1-dep2-name",
"compiled-pkg1-dep2-fingerprint",
"",
"compiled-pkg1-dep2-os-version-slug",
"compiled-pkg1-dep2-path",
"compiled-pkg1-dep2-sha1",
Expand Down
13 changes: 7 additions & 6 deletions release/archive_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ func (r ArchiveReader) newRelease(manifest boshman.Manifest, extractPath string)
commitHash: manifest.CommitHash,
uncommittedChanges: manifest.UncommittedChanges,

jobs: jobs,
packages: packages,
compiledPkgs: compiledPkgs,
license: license,
noCompression: manifest.NoCompression,
jobs: jobs,
packages: packages,
compiledPkgs: compiledPkgs,
compileTimePkgs: manifest.CompileTimePackages,
license: license,
noCompression: manifest.NoCompression,

extractedPath: extractPath,
fs: r.fs,
Expand Down Expand Up @@ -194,7 +195,7 @@ func (r ArchiveReader) newCompiledPackages(refs []boshman.CompiledPackageRef, ex
archivePath := filepath.Join(extractPath, "compiled_packages", ref.Name+".tgz")

compiledPkg := boshpkg.NewCompiledPackageWithArchive(
ref.Name, ref.Fingerprint, ref.OSVersionSlug, archivePath, ref.SHA1, ref.Dependencies)
ref.Name, ref.Fingerprint, ref.OriginalFingerprint, ref.OSVersionSlug, archivePath, ref.SHA1, ref.Dependencies)

compiledPkgs = append(compiledPkgs, compiledPkg)
}
Expand Down
14 changes: 12 additions & 2 deletions release/archive_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,17 @@ compiled_packages:
- name: pkg1
version: pkg1-version
fingerprint: pkg1-fp
original_fingerprint: original-pkg1-fp
stemcell: pkg1-stemcell
sha1: pkg1-sha
dependencies: [pkg2]

compile_time_packages:
- name: compile-time-pkg
version: compile-time-version
fingerprint: compile-time-fingerprint
dependencies: [pkg1]

license:
version: lic-version
fingerprint: lic-fp
Expand All @@ -273,10 +280,10 @@ license:
job2 := boshjob.NewJob(NewResource("job2", "job2-fp", nil))

compiledPkg1 := boshpkg.NewCompiledPackageWithArchive(
"pkg1", "pkg1-fp", "pkg1-stemcell",
"pkg1", "pkg1-fp", "original-pkg1-fp", "pkg1-stemcell",
filepath.Join("/", "extracted", "release", "compiled_packages", "pkg1.tgz"), "pkg1-sha", []string{"pkg2"})
compiledPkg2 := boshpkg.NewCompiledPackageWithArchive(
"pkg2", "pkg2-fp", "pkg2-stemcell",
"pkg2", "pkg2-fp", "", "pkg2-stemcell",
filepath.Join("/", "extracted", "release", "compiled_packages", "pkg2.tgz"), "pkg2-sha", nil)
err := compiledPkg1.AttachDependencies([]*boshpkg.CompiledPackage{compiledPkg2})
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -318,6 +325,9 @@ license:
Expect(release.Packages()).To(BeEmpty())
Expect(release.CompiledPackages()).To(Equal(
[]*boshpkg.CompiledPackage{compiledPkg2, compiledPkg1}))
Expect(release.CompiledPackages()[1].OriginalFingerprint()).To(Equal("original-pkg1-fp"))
Expect(release.CopyWith(nil, nil, nil, nil).Manifest().CompileTimePackages).To(HaveLen(1))
Expect(release.CopyWith(nil, nil, nil, nil).Manifest().CompileTimePackages[0].Name).To(Equal("compile-time-pkg"))
Expect(release.IsCompiled()).To(BeTrue())
Expect(release.License()).To(Equal(lic))

Expand Down
14 changes: 7 additions & 7 deletions release/archive_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ no_compression: true
Expect(err).ToNot(HaveOccurred())

release.CompiledPackagesReturns([]*boshpkg.CompiledPackage{
boshpkg.NewCompiledPackageWithArchive("cp1", "", "", filepath.Join("/", "tmp", "cp1.tgz"), "", nil),
boshpkg.NewCompiledPackageWithArchive("cp2", "", "", filepath.Join("/", "tmp", "cp2.tgz"), "", nil),
boshpkg.NewCompiledPackageWithArchive("cp1", "", "", "", filepath.Join("/", "tmp", "cp1.tgz"), "", nil),
boshpkg.NewCompiledPackageWithArchive("cp2", "", "", "", filepath.Join("/", "tmp", "cp2.tgz"), "", nil),
})

err = fs.WriteFileString(filepath.Join("/", "tmp", "lic.tgz"), "license-content")
Expand Down Expand Up @@ -417,8 +417,8 @@ no_compression: true
Expect(err).ToNot(HaveOccurred())

release.CompiledPackagesReturns([]*boshpkg.CompiledPackage{
boshpkg.NewCompiledPackageWithArchive("cp1", "", "", filepath.Join("/", "tmp", "cp1.tgz"), "", nil),
boshpkg.NewCompiledPackageWithArchive("cp2", "", "", filepath.Join("/", "tmp", "cp2.tgz"), "", nil),
boshpkg.NewCompiledPackageWithArchive("cp1", "", "", "", filepath.Join("/", "tmp", "cp1.tgz"), "", nil),
boshpkg.NewCompiledPackageWithArchive("cp2", "", "", "", filepath.Join("/", "tmp", "cp2.tgz"), "", nil),
})

compressor.CompressSpecificFilesInDirCallBack = func() {
Expand All @@ -445,8 +445,8 @@ no_compression: true
Expect(err).ToNot(HaveOccurred())

release.CompiledPackagesReturns([]*boshpkg.CompiledPackage{
boshpkg.NewCompiledPackageWithArchive("cp1", "cp1-fp", "", filepath.Join("/", "tmp", "cp1.tgz"), "", nil),
boshpkg.NewCompiledPackageWithArchive("cp2", "cp2-fp", "", filepath.Join("/", "tmp", "cp2.tgz"), "", nil),
boshpkg.NewCompiledPackageWithArchive("cp1", "cp1-fp", "", "", filepath.Join("/", "tmp", "cp1.tgz"), "", nil),
boshpkg.NewCompiledPackageWithArchive("cp2", "cp2-fp", "", "", filepath.Join("/", "tmp", "cp2.tgz"), "", nil),
})

compressor.CompressSpecificFilesInDirCallBack = func() {
Expand All @@ -467,7 +467,7 @@ no_compression: true
fs.CopyFileError = errors.New("fake-err")

release.CompiledPackagesReturns([]*boshpkg.CompiledPackage{
boshpkg.NewCompiledPackageWithArchive("cp1", "", "", filepath.Join("/", "tmp", "cp1.tgz"), "", nil),
boshpkg.NewCompiledPackageWithArchive("cp1", "", "", "", filepath.Join("/", "tmp", "cp1.tgz"), "", nil),
})

_, err := act()
Expand Down
8 changes: 4 additions & 4 deletions release/job/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ var _ = Describe("Job", func() {
job := NewJob(NewResource("name", "fp", nil))
job.PackageNames = []string{"pkg1", "pkg2"}

pkg1 := boshpkg.NewCompiledPackageWithArchive("pkg1", "fp", "", "path", "sha1", nil)
pkg2 := boshpkg.NewCompiledPackageWithArchive("pkg2", "fp", "", "path", "sha1", nil)
unusedPkg := boshpkg.NewCompiledPackageWithArchive("unused", "fp", "", "path", "sha1", nil)
pkg1 := boshpkg.NewCompiledPackageWithArchive("pkg1", "fp", "", "", "path", "sha1", nil)
pkg2 := boshpkg.NewCompiledPackageWithArchive("pkg2", "fp", "", "", "path", "sha1", nil)
unusedPkg := boshpkg.NewCompiledPackageWithArchive("unused", "fp", "", "", "path", "sha1", nil)

err := job.AttachCompilablePackages([]boshpkg.Compilable{pkg1, unusedPkg, pkg2})
Expect(err).ToNot(HaveOccurred())
Expand All @@ -112,7 +112,7 @@ var _ = Describe("Job", func() {
job := NewJob(NewResource("name", "fp", nil))
job.PackageNames = []string{"pkg1"}

pkg2 := boshpkg.NewCompiledPackageWithArchive("pkg2", "fp", "", "path", "sha1", nil)
pkg2 := boshpkg.NewCompiledPackageWithArchive("pkg2", "fp", "", "", "path", "sha1", nil)

err := job.AttachCompilablePackages([]boshpkg.Compilable{pkg2})
Expect(err).To(HaveOccurred())
Expand Down
31 changes: 20 additions & 11 deletions release/manifest/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ type Manifest struct {
CommitHash string `yaml:"commit_hash"`
UncommittedChanges bool `yaml:"uncommitted_changes"`

Jobs []JobRef `yaml:"jobs,omitempty"`
Packages []PackageRef `yaml:"packages,omitempty"`
CompiledPkgs []CompiledPackageRef `yaml:"compiled_packages,omitempty"`
License *LicenseRef `yaml:"license,omitempty"`
NoCompression bool `yaml:"no_compression"`
Jobs []JobRef `yaml:"jobs,omitempty"`
Packages []PackageRef `yaml:"packages,omitempty"`
CompiledPkgs []CompiledPackageRef `yaml:"compiled_packages,omitempty"`
CompileTimePackages []CompileTimePackageRef `yaml:"compile_time_packages,omitempty"`
License *LicenseRef `yaml:"license,omitempty"`
NoCompression bool `yaml:"no_compression"`
}

type JobRef struct {
Expand All @@ -39,12 +40,20 @@ type PackageRef struct {
}

type CompiledPackageRef struct {
Name string `yaml:"name"`
Version string `yaml:"version"` // todo deprecate
Fingerprint string `yaml:"fingerprint"`
SHA1 string `yaml:"sha1"`
OSVersionSlug string `yaml:"stemcell"`
Dependencies []string `yaml:"dependencies"`
Name string `yaml:"name"`
Version string `yaml:"version"` // todo deprecate
Fingerprint string `yaml:"fingerprint"`
OriginalFingerprint string `yaml:"original_fingerprint,omitempty"`
SHA1 string `yaml:"sha1"`
OSVersionSlug string `yaml:"stemcell"`
Dependencies []string `yaml:"dependencies"`
}

type CompileTimePackageRef struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Fingerprint string `yaml:"fingerprint"`
Dependencies []string `yaml:"dependencies"`
}

type LicenseRef struct {
Expand Down
73 changes: 73 additions & 0 deletions release/manifest/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
fakesys "github.com/cloudfoundry/bosh-utils/system/fakes"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"gopkg.in/yaml.v3"

. "github.com/cloudfoundry/bosh-cli/v7/release/manifest"
)
Expand Down Expand Up @@ -41,6 +42,11 @@ packages:
cGtnMS1mcA==
version: !binary |-
cGtnMS12ZXJzaW9u

compiled_packages:
- name: compiled-pkg
fingerprint: compiled-fingerprint
sha1: compiled-sha1
`)
Expect(err).ToNot(HaveOccurred())

Expand All @@ -54,5 +60,72 @@ packages:
Expect(manifest.Packages[0].SHA1).To(Equal("pkg1-sha1"))
Expect(manifest.Packages[0].Fingerprint).To(Equal("pkg1-fp"))
Expect(manifest.Packages[0].Version).To(Equal("pkg1-version"))
Expect(manifest.CompileTimePackages).To(BeEmpty())
Expect(manifest.CompiledPkgs[0].OriginalFingerprint).To(BeEmpty())
})

It("decodes compile-time package metadata and original compiled package fingerprints", func() {
err := fs.WriteFileString("/release.yml", `---
name: release
version: version
compile_time_packages:
- name: compile-pkg
version: compile-version
fingerprint: compile-fingerprint
dependencies:
- dependency
compiled_packages:
- name: compiled-pkg
version: compiled-version
fingerprint: compiled-fingerprint
original_fingerprint: original-fingerprint
sha1: compiled-sha1
stemcell: ubuntu-jammy
dependencies:
- dependency
`)
Expect(err).NotTo(HaveOccurred())

manifest, err := NewManifestFromPath("/release.yml", fs)
Expect(err).NotTo(HaveOccurred())

Expect(manifest.CompileTimePackages).To(Equal([]CompileTimePackageRef{{
Name: "compile-pkg",
Version: "compile-version",
Fingerprint: "compile-fingerprint",
Dependencies: []string{"dependency"},
}}))
Expect(manifest.CompiledPkgs[0].OriginalFingerprint).To(Equal("original-fingerprint"))
})

It("omits compile-time package metadata and original fingerprints when empty", func() {
data, err := yaml.Marshal(Manifest{
Name: "release",
Version: "version",
CompiledPkgs: []CompiledPackageRef{{Name: "compiled-pkg"}},
})
Expect(err).NotTo(HaveOccurred())
Expect(string(data)).NotTo(ContainSubstring("compile_time_packages:"))
Expect(string(data)).NotTo(ContainSubstring("original_fingerprint:"))
})

It("marshals compile-time package metadata and original fingerprints when set", func() {
manifest := Manifest{
CompileTimePackages: []CompileTimePackageRef{{
Name: "compile-pkg",
Version: "compile-version",
Fingerprint: "compile-fingerprint",
Dependencies: []string{"dependency"},
}},
CompiledPkgs: []CompiledPackageRef{{
Name: "compiled-pkg",
OriginalFingerprint: "original-fingerprint",
}},
}

data, err := yaml.Marshal(manifest)
Expect(err).NotTo(HaveOccurred())
Expect(string(data)).To(ContainSubstring("compile_time_packages:"))
Expect(string(data)).To(ContainSubstring("original_fingerprint: original-fingerprint"))
})
})
11 changes: 6 additions & 5 deletions release/manifest_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ func (r ManifestReader) newRelease(manifest boshman.Manifest) (Release, error) {
commitHash: manifest.CommitHash,
uncommittedChanges: manifest.UncommittedChanges,

jobs: jobs,
packages: packages,
compiledPkgs: compiledPkgs,
license: license,
jobs: jobs,
packages: packages,
compiledPkgs: compiledPkgs,
compileTimePkgs: manifest.CompileTimePackages,
license: license,

fs: r.fs,
}
Expand Down Expand Up @@ -137,7 +138,7 @@ func (r ManifestReader) newCompiledPackages(refs []boshman.CompiledPackageRef) (

for _, ref := range refs {
compiledPkg := boshpkg.NewCompiledPackageWithoutArchive(
ref.Name, ref.Fingerprint, ref.OSVersionSlug, ref.SHA1, ref.Dependencies)
ref.Name, ref.Fingerprint, ref.OriginalFingerprint, ref.OSVersionSlug, ref.SHA1, ref.Dependencies)

compiledPkgs = append(compiledPkgs, compiledPkg)
}
Expand Down
Loading
Loading