Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes caching by accounting for dep_date at metadata root level #309

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ func (l *LayerContributor) normalizeDependencyDeprecationDate(input map[string]i
break
}
}
} else if depr_date, ok := input["deprecation_date"]; ok {
deprecationDate, err := l.parseDeprecationDate(depr_date)
dmikusa marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return err
}
input["deprecation_date"] = deprecationDate
}

return nil
Expand Down
50 changes: 50 additions & 0 deletions layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,56 @@ func testLayer(t *testing.T, context spec.G, it spec.S) {
Expect(called).To(BeFalse())
})

it("does not contribute when deprecation_date is found on metadata map root", func() {
dependency = libpak.BuildpackDependency{
ID: "test-id",
Name: "test-name",
Version: "1.1.1",
URI: fmt.Sprintf("%s/test-path", server.URL()),
SHA256: "576dd8416de5619ea001d9662291d62444d1292a38e96956bc4651c01f14bca1",
Stacks: []string{"test-stack"},
Licenses: []libpak.BuildpackDependencyLicense{
{
Type: "test-type",
URI: "test-uri",
},
},
CPEs: []string{"cpe:2.3:a:some:jre:11.0.2:*:*:*:*:*:*:*"},
PURL: "pkg:generic/[email protected]?arch=amd64",
}
dlc.ExpectedMetadata = dependency

layer.Metadata = map[string]interface{}{
"id": dependency.ID,
"name": dependency.Name,
"version": dependency.Version,
"uri": dependency.URI,
"sha256": dependency.SHA256,
"stacks": []interface{}{dependency.Stacks[0]},
"licenses": []map[string]interface{}{
{
"type": dependency.Licenses[0].Type,
"uri": dependency.Licenses[0].URI,
},
},
"cpes": []interface{}{"cpe:2.3:a:some:jre:11.0.2:*:*:*:*:*:*:*"},
"purl": "pkg:generic/[email protected]?arch=amd64",
"deprecation_date": "0001-01-01T00:00:00Z",
}

var called bool

_, err := dlc.Contribute(layer, func(artifact *os.File) (libcnb.Layer, error) {
defer artifact.Close()

called = true
return layer, nil
})
Expect(err).NotTo(HaveOccurred())

Expect(called).To(BeFalse())
})

it("does not call function with missing deprecation_date", func() {
dependency = libpak.BuildpackDependency{
ID: "test-id",
Expand Down