diff --git a/buildmodule.go b/buildmodule.go index 36d76d7..4cb3a01 100644 --- a/buildmodule.go +++ b/buildmodule.go @@ -95,6 +95,31 @@ type BuildModuleDependency 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 BuildModuleDependency) 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 (b BuildModuleDependency) Equals(b2 BuildModuleDependency) bool { diff --git a/layer.go b/layer.go index a1ed94a..ee666e1 100644 --- a/layer.go +++ b/layer.go @@ -224,7 +224,7 @@ func NewDependencyLayerContributor(dependency BuildModuleDependency, cache Depen return DependencyLayerContributor{ Dependency: dependency, DependencyCache: cache, - ExpectedMetadata: dependency, + ExpectedMetadata: dependency.GetMetadata(), ExpectedTypes: types, Logger: logger, }