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

When additional buildpack is missing version, try to use the latest one #1873

Merged
merged 2 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions internal/commands/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ version = "1.0"
h.AssertNil(t, command.Execute())
})
})

when("file has a builder specified", func() {
var projectTomlPath string

Expand Down Expand Up @@ -608,6 +609,7 @@ builder = "my-builder"
})
})
})

when("file is invalid", func() {
var projectTomlPath string

Expand Down
4 changes: 3 additions & 1 deletion pkg/client/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,8 +1099,10 @@ func getBuildpackLocator(bp projectTypes.Buildpack, stackID string) (string, err
return bp.URI, nil
case bp.ID != "" && bp.Version != "":
return fmt.Sprintf("%s@%s", bp.ID, bp.Version), nil
case bp.ID != "" && bp.Version == "":
return bp.ID, nil
default:
return "", errors.New("Invalid buildpack defined in project descriptor")
return "", errors.New("Invalid buildpack definition")
}
}

Expand Down
27 changes: 26 additions & 1 deletion pkg/client/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,29 @@ api = "0.2"
)
})

when("from project descriptor", func() {
when("id - no version is provided", func() {
it("resolves version", func() {
h.AssertNil(t, subject.Build(context.TODO(), BuildOptions{
Image: "some/app",
Builder: defaultBuilderName,
ClearCache: true,
ProjectDescriptor: projectTypes.Descriptor{
Build: projectTypes.Build{Buildpacks: []projectTypes.Buildpack{{ID: "buildpack.1.id"}}},
},
}))
h.AssertEq(t, fakeLifecycle.Opts.Builder.Name(), defaultBuilderImage.Name())

assertOrderEquals(`[[order]]

[[order.group]]
id = "buildpack.1.id"
version = "buildpack.1.version"
`)
})
})
})

when("buildpacks include URIs", func() {
var buildpackTgz string

Expand Down Expand Up @@ -1405,6 +1428,7 @@ api = "0.2"
{ID: "some-other-buildpack-id", Version: "some-other-buildpack-version"},
})
})

it("adds the pre buildpack from the project descriptor", func() {
err := subject.Build(context.TODO(), BuildOptions{
Image: "some/app",
Expand Down Expand Up @@ -1519,6 +1543,7 @@ api = "0.2"
{ID: "buildpack.2.id", Version: "buildpack.2.version"},
})
})

it("not added from the project descriptor", func() {
err := subject.Build(context.TODO(), BuildOptions{
Image: "some/app",
Expand Down Expand Up @@ -1716,7 +1741,7 @@ api = "0.2"
ProjectDescriptorBaseDir: tmpDir,
})

h.AssertEq(t, "Invalid buildpack defined in project descriptor", err.Error())
h.AssertEq(t, "Invalid buildpack definition", err.Error())
})

it("ignores script if there is a URI", func() {
Expand Down
Loading