Skip to content

Commit 0f06618

Browse files
committed
Introduce struct with metadata to identify a dependency
Signed-off-by: Ralf Pannemans <[email protected]>
1 parent 9588657 commit 0f06618

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

buildmodule.go

+25
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,31 @@ type BuildModuleDependency struct {
9595
DeprecationDate time.Time `toml:"deprecation_date"`
9696
}
9797

98+
// DependencyLayerContributorMetadata returns the subset of data from BuildpackDependency that is use as expected metadata for the DependencyLayerContributor.
99+
type DependencyLayerContributorMetadata struct {
100+
// ID is the dependency ID.
101+
ID string `toml:"id"`
102+
103+
// Name is the dependency name.
104+
Name string `toml:"name"`
105+
106+
// Version is the dependency version.
107+
Version string `toml:"version"`
108+
109+
// SHA256 is the hash of the dependency.
110+
SHA256 string `toml:"sha256"`
111+
}
112+
113+
// GetMetadata return the relevant metadata of this dependency
114+
func (b BuildpackDependency) GetMetadata() DependencyLayerContributorMetadata {
115+
return DependencyLayerContributorMetadata{
116+
ID: b.ID,
117+
Name: b.Name,
118+
Version: b.Version,
119+
SHA256: b.SHA256,
120+
}
121+
}
122+
98123
// Equals compares the 2 structs if they are equal. This is very simiar to reflect.DeepEqual
99124
// except that properties that will not work (e.g. DeprecationDate) are ignored.
100125
func (b1 BuildModuleDependency) Equals(b2 BuildModuleDependency) bool {

layer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ type DependencyLayerContributor struct {
218218
func NewDependencyLayerContributor(dependency BuildModuleDependency, cache DependencyCache, types libcnb.LayerTypes) DependencyLayerContributor {
219219
return DependencyLayerContributor{
220220
Dependency: dependency,
221-
ExpectedMetadata: dependency,
221+
ExpectedMetadata: dependency.GetMetadata(),
222222
DependencyCache: cache,
223223
ExpectedTypes: types,
224224
}

0 commit comments

Comments
 (0)