Skip to content

Commit

Permalink
Merge pull request #1825 from ctrox/empty-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkennedy513 authored Feb 25, 2025
2 parents 7de12b1 + 831fcdf commit 3033eeb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/cnb/buildpack_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ func (bl BuildpackLayerInfo) supports(buildpackApis []string, id string, mixins
return errors.Errorf("unsupported buildpack api: %s, expecting: %s", bl.API, strings.Join(buildpackApis, ", "))
}

// as of buildpack API 0.10+ stacks are optional (and deprecated)
if len(bl.Stacks) == 0 {
return nil
}

for _, s := range bl.Stacks {
buildpackVersion, err := semver.NewVersion(bl.API)
if err != nil {
Expand Down
20 changes: 20 additions & 0 deletions pkg/cnb/create_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,26 @@ func testCreateBuilderOs(os string, t *testing.T, when spec.G, it spec.S) {
require.EqualError(t, err, "validating buildpack io.buildpack.unsupported.stack@v4: stack io.buildpacks.stacks.some-stack is not supported")
})

it("works with empty stack", func() {
addBuildpack(t, "io.buildpack.empty.stack", "v4", "buildpack.4.com", "0.2", []corev1alpha1.BuildpackStack{})

clusterBuilderSpec.Order = []buildapi.BuilderOrderEntry{
{
Group: []buildapi.BuilderBuildpackRef{{
BuildpackRef: corev1alpha1.BuildpackRef{
BuildpackInfo: corev1alpha1.BuildpackInfo{
Id: "io.buildpack.empty.stack",
Version: "v4",
},
},
}},
},
}

_, err := subject.CreateBuilder(ctx, builderKeychain, stackKeychain, fetcher, stack, clusterBuilderSpec, []*corev1.Secret{}, builderTag)
require.NoError(t, err)
})

it("errors with unsupported mixin", func() {
addBuildpack(t, "io.buildpack.unsupported.mixin", "v4", "buildpack.1.com", "0.2",
[]corev1alpha1.BuildpackStack{
Expand Down

0 comments on commit 3033eeb

Please sign in to comment.