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

Creator errors if detected order contains extensions #1246

Merged
merged 1 commit into from
Nov 15, 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
23 changes: 23 additions & 0 deletions acceptance/creator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,29 @@ func testCreatorFunc(platformAPI string) func(t *testing.T, when spec.G, it spec
})
})

when("detected order contains extensions", func() {
it("errors", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.10"), "")
cmd := exec.Command(
"docker", "run", "--rm",
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+createRegAuthConfig,
"--network", createRegNetwork,
createImage,
ctrPath(creatorPath),
"-log-level", "debug",
"-order", "/cnb/order-with-extensions.toml",
"-run-image", createRegFixtures.ReadOnlyRunImage,
createRegFixtures.SomeAppImage,
) // #nosec G204
output, err := cmd.CombinedOutput()

h.AssertNotNil(t, err)
expected := "detected order contains extensions which is not supported by the creator"
h.AssertStringContains(t, string(output), expected)
})
})

when("daemon case", func() {
it.After(func() {
h.DockerImageRemove(t, createdImageName)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Buildpack API version
api = "0.9"

# Extension ID and metadata
[extension]
id = "samples/hello-world"
version = "0.0.1"
name = "Hello World Extension"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[[order]]
[[order.group]]
id = "samples/hello-world"
version = "0.0.1"

[[order-extensions]]
[[order-extensions.group]]
id = "samples/hello-world"
version = "0.0.1"
9 changes: 8 additions & 1 deletion cmd/lifecycle/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (c *createCmd) Exec() error {
if err != nil {
return err
}
dirStore := platform.NewDirStore(c.BuildpacksDir, "")
dirStore := platform.NewDirStore(c.BuildpacksDir, c.ExtensionsDir)
if err != nil {
return err
}
Expand Down Expand Up @@ -159,6 +159,13 @@ func (c *createCmd) Exec() error {
if err != nil {
return err // pass through error
}
if group.HasExtensions() {
return cmd.FailErrCode(
errors.New("detected order contains extensions which is not supported by the creator"),
c.CodeFor(platform.DetectError),
"detect",
)
}

// Restore
if !c.SkipLayers || c.PlatformAPI.AtLeast("0.10") {
Expand Down