diff --git a/buildpack.go b/buildpack.go index e1c2d5c..67fbdf5 100644 --- a/buildpack.go +++ b/buildpack.go @@ -96,6 +96,31 @@ type BuildpackDependency struct { DeprecationDate time.Time `toml:"deprecation_date"` } +// DependencyLayerContributorMetadata returns the subset of data from BuildpackDependency that is use as expected metadata for the DependencyLayerContributor. +type DependencyLayerContributorMetadata struct { + // ID is the dependency ID. + ID string `toml:"id"` + + // Name is the dependency name. + Name string `toml:"name"` + + // Version is the dependency version. + Version string `toml:"version"` + + // SHA256 is the hash of the dependency. + SHA256 string `toml:"sha256"` +} + +// GetMetadata return the relevant metadata of this dependency +func (b BuildpackDependency) GetMetadata() DependencyLayerContributorMetadata { + return DependencyLayerContributorMetadata{ + ID: b.ID, + Name: b.Name, + Version: b.Version, + SHA256: b.SHA256, + } +} + // Equals compares the 2 structs if they are equal. This is very simiar to reflect.DeepEqual // except that properties that will not work (e.g. DeprecationDate) are ignored. func (b1 BuildpackDependency) Equals(b2 BuildpackDependency) bool { diff --git a/layer.go b/layer.go index d4b0050..40117bc 100644 --- a/layer.go +++ b/layer.go @@ -237,7 +237,7 @@ func NewDependencyLayer(dependency BuildpackDependency, cache DependencyCache, t func NewDependencyLayerContributor(dependency BuildpackDependency, cache DependencyCache, types libcnb.LayerTypes) DependencyLayerContributor { return DependencyLayerContributor{ Dependency: dependency, - ExpectedMetadata: dependency, + ExpectedMetadata: dependency.GetMetadata(), DependencyCache: cache, ExpectedTypes: types, }