Skip to content

Commit

Permalink
Make extensions not experimental for Platform 0.13 and above (#1295)
Browse files Browse the repository at this point in the history
* Make extensions not experimental for Platform 0.13 and above

Signed-off-by: Prashant Rewar <108176843+prashantrewar@users.noreply.github.com>

* Fix failing acceptance test

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Prashant Rewar <108176843+prashantrewar@users.noreply.github.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
  • Loading branch information
prashantrewar and natalieparellano authored Feb 15, 2024
1 parent 7bdfb33 commit 92bb4fb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
11 changes: 9 additions & 2 deletions acceptance/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ fail: fail_detect_buildpack@some_version`
})

it("processes the provided order.toml", func() {
experimentalMode := "warn"
if api.MustParse(platformAPI).AtLeast("0.13") {
experimentalMode = "error"
}

output := h.DockerRunAndCopy(t,
containerName,
copyDir,
Expand All @@ -365,7 +370,7 @@ fail: fail_detect_buildpack@some_version`
"--user", userID,
"--volume", orderPath+":/layers/order.toml",
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_EXPERIMENTAL_MODE=warn", // required as the default is `error` if unset
"--env", "CNB_EXPERIMENTAL_MODE="+experimentalMode,
),
h.WithArgs(
"-analyzed=/layers/analyzed.toml",
Expand All @@ -377,7 +382,9 @@ fail: fail_detect_buildpack@some_version`
)

t.Log("runs /bin/detect for buildpacks and extensions")
h.AssertStringContains(t, output, "Platform requested experimental feature 'Dockerfiles'")
if api.MustParse(platformAPI).LessThan("0.13") {
h.AssertStringContains(t, output, "Platform requested experimental feature 'Dockerfiles'")
}
h.AssertStringContains(t, output, "FOO=val-from-build-config")
h.AssertStringContains(t, output, "simple_extension: output from /bin/detect")
t.Log("writes group.toml")
Expand Down
14 changes: 12 additions & 2 deletions acceptance/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,16 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
runImageFixtureTopLayerSHA := layers[len(layers)-1]
runImageFixtureSHA := inspect.ID

experimentalMode := "warn"
if api.MustParse(platformAPI).AtLeast("0.13") {
experimentalMode = "error"
}

output := h.DockerRun(t,
exportImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_EXPERIMENTAL_MODE=warn",
"--env", "CNB_EXPERIMENTAL_MODE="+experimentalMode,
"--env", "CNB_PLATFORM_API="+platformAPI,
)...),
h.WithArgs(exportArgs...),
Expand Down Expand Up @@ -411,10 +416,15 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
runImageFixtureSHA, err := remoteImage.Digest()
h.AssertNil(t, err)

experimentalMode := "warn"
if api.MustParse(platformAPI).AtLeast("0.13") {
experimentalMode = "error"
}

output := h.DockerRun(t,
exportImage,
h.WithFlags(
"--env", "CNB_EXPERIMENTAL_MODE=warn",
"--env", "CNB_EXPERIMENTAL_MODE="+experimentalMode,
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+exportRegAuthConfig,
"--network", exportRegNetwork,
Expand Down
2 changes: 1 addition & 1 deletion cmd/lifecycle/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (d *detectCmd) Exec() error {
if err != nil {
return unwrapErrorFailWithMessage(err, "initialize detector")
}
if detector.HasExtensions {
if detector.HasExtensions && detector.PlatformAPI.LessThan("0.13") {
if err = platform.GuardExperimental(platform.FeatureDockerfiles, cmd.DefaultLogger); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/lifecycle/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (e *exportCmd) Exec() error {
if err != nil {
return err
}
if e.hasExtendedLayers() {
if e.hasExtendedLayers() && e.PlatformAPI.LessThan("0.13") {
if err := platform.GuardExperimental(platform.FeatureDockerfiles, cmd.DefaultLogger); err != nil {
return err
}
Expand Down

0 comments on commit 92bb4fb

Please sign in to comment.