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

Enable experimental in exporter if we are using extensions #1724

Merged
merged 1 commit into from
Apr 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
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