Skip to content

Commit

Permalink
Add support for wild-card stacks in dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Sambhav Kothari <skothari44@bloomberg.net>
  • Loading branch information
sambhav authored and ForestEckhardt committed Aug 4, 2022
1 parent 3e01d1e commit ba6658c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion postal/buildpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func parseBuildpack(path, name string) ([]Dependency, string, error) {

func stacksInclude(stacks []string, stack string) bool {
for _, s := range stacks {
if s == stack {
if s == stack || s == "*" {
return true
}
}
Expand Down
23 changes: 23 additions & 0 deletions postal/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ stacks = ["some-stack"]
uri = "some-uri"
version = "4.5.6"
strip-components = 1
[[metadata.dependencies]]
id = "some-other-entry"
sha256 = "some-sha"
stacks = ["*"]
uri = "some-uri"
version = "4.5.6"
strip-components = 1
`)
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -115,6 +123,21 @@ strip-components = 1
}))
})

context("when the dependency has a wildcard stack", func() {
it("is compatible with all stack ids", func() {
dependency, err := service.Resolve(path, "some-other-entry", "", "random-stack")
Expect(err).NotTo(HaveOccurred())
Expect(dependency).To(Equal(postal.Dependency{
ID: "some-other-entry",
Stacks: []string{"*"},
URI: "some-uri",
SHA256: "some-sha",
Version: "4.5.6",
StripComponents: 1,
}))
})
})

context("when there is NOT a default version", func() {
context("when the entry version is empty", func() {
it("picks the dependency with the highest semantic version number", func() {
Expand Down

0 comments on commit ba6658c

Please sign in to comment.