Skip to content

Commit 153d0e9

Browse files
jjbustamanteclaude
andcommitted
Add -run flag support for restorer in Platform API 0.14
This implements the missing feature from Platform API 0.14 where the restorer should accept a -run flag to enable read access validation for run images selected by extensions during the restore phase. When extensions switch the run image to one listed in run.toml, the restorer needs to verify accessibility using the platform's authentication context (CNB_REGISTRY_AUTH). This prevents builds from proceeding with images the system cannot actually access. Changes: - Add -run flag to restorer when Platform API >= 0.14 - Write run.toml file via WriteRunToml operation - Add tests verifying flag is present for Platform API >= 0.14 - Add tests verifying flag is absent for Platform API < 0.14 Fixes #2515 References: - Spec PR: buildpacks/spec#408 - Lifecycle PR: buildpacks/lifecycle#1364 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
1 parent 94348a5 commit 153d0e9

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

internal/build/lifecycle_execution.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,13 @@ func (l *LifecycleExecution) Restore(ctx context.Context, buildCache Cache, kani
551551
}
552552
}
553553

554+
// for run
555+
runOp := NullOp()
556+
if l.platformAPI.AtLeast("0.14") {
557+
flags = append(flags, "-run", l.mountPaths.runPath())
558+
runOp = WithContainerOperations(WriteRunToml(l.mountPaths.runPath(), l.opts.Builder.RunImages(), l.os))
559+
}
560+
554561
// for kaniko
555562
kanikoCacheBindOp := NullOp()
556563
if (l.platformAPI.AtLeast("0.10") && l.hasExtensionsForBuild()) ||
@@ -607,6 +614,7 @@ func (l *LifecycleExecution) Restore(ctx context.Context, buildCache Cache, kani
607614
cacheBindOp,
608615
dockerOp,
609616
flagsOp,
617+
runOp,
610618
kanikoCacheBindOp,
611619
registryOp,
612620
layoutOp,

internal/build/lifecycle_execution_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,6 +2046,28 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) {
20462046
})
20472047
})
20482048

2049+
when("platform >= 0.14", func() {
2050+
platformAPI = api.MustParse("0.14")
2051+
2052+
it("provides -run flag", func() {
2053+
h.AssertIncludeAllExpectedPatterns(t,
2054+
configProvider.ContainerConfig().Cmd,
2055+
[]string{"-run", "/layers/run.toml"},
2056+
)
2057+
})
2058+
})
2059+
2060+
when("platform < 0.14", func() {
2061+
platformAPI = api.MustParse("0.13")
2062+
2063+
it("does not provide -run flag", func() {
2064+
h.AssertSliceNotContains(t,
2065+
configProvider.ContainerConfig().Cmd,
2066+
"-run",
2067+
)
2068+
})
2069+
})
2070+
20492071
when("layout is true", func() {
20502072
when("platform >= 0.12", func() {
20512073
platformAPI = api.MustParse("0.12")

0 commit comments

Comments
 (0)