Skip to content

Commit

Permalink
Merge pull request #1724 from buildpacks/add-experimental
Browse files Browse the repository at this point in the history
Enable experimental in exporter if we are using extensions
  • Loading branch information
jkutner authored Apr 15, 2023
2 parents afff088 + 9e2a6e0 commit 4ac7a78
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/build/lifecycle_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,10 +715,14 @@ func (l *LifecycleExecution) Export(ctx context.Context, buildCache, launchCache
"-cache-dir", l.mountPaths.cacheDir(),
}

expEnv := NullOp()
if l.platformAPI.LessThan("0.12") {
flags = append(flags, "-stack", l.mountPaths.stackPath())
} else {
flags = append(flags, "-run", l.mountPaths.runPath())
if l.hasExtensionsForRun() {
expEnv = WithEnv("CNB_EXPERIMENTAL_MODE=warn")
}
}

if l.platformAPI.LessThan("0.7") {
Expand All @@ -740,9 +744,9 @@ func (l *LifecycleExecution) Export(ctx context.Context, buildCache, launchCache
cacheBindOp = WithBinds(fmt.Sprintf("%s:%s", buildCache.Name(), l.mountPaths.cacheDir()))
}

withEnv := NullOp()
epochEnv := NullOp()
if l.opts.CreationTime != nil && l.platformAPI.AtLeast("0.9") {
withEnv = WithEnv(fmt.Sprintf("%s=%s", sourceDateEpochEnv, strconv.Itoa(int(l.opts.CreationTime.Unix()))))
epochEnv = WithEnv(fmt.Sprintf("%s=%s", sourceDateEpochEnv, strconv.Itoa(int(l.opts.CreationTime.Unix()))))
}

opts := []PhaseConfigProviderOperation{
Expand Down Expand Up @@ -771,7 +775,8 @@ func (l *LifecycleExecution) Export(ctx context.Context, buildCache, launchCache
If(l.opts.Interactive, WithPostContainerRunOperations(
EnsureVolumeAccess(l.opts.Builder.UID(), l.opts.Builder.GID(), l.os, l.layersVolume, l.appVolume),
CopyOut(l.opts.Termui.ReadLayers, l.mountPaths.layersDir(), l.mountPaths.appDir()))),
withEnv,
epochEnv,
expEnv,
}

var export RunnerCleaner
Expand Down
10 changes: 10 additions & 0 deletions internal/build/lifecycle_execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,16 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) {
)
h.AssertSliceNotContains(t, configProvider.ContainerConfig().Cmd, "-stack")
})

when("extensions", func() {
when("for run", func() {
extensionsForRun = true

it("sets CNB_EXPERIMENTAL_MODE=warn in the environment", func() {
h.AssertSliceContains(t, configProvider.ContainerConfig().Env, "CNB_EXPERIMENTAL_MODE=warn")
})
})
})
})

when("additional tags are specified", func() {
Expand Down

0 comments on commit 4ac7a78

Please sign in to comment.