Skip to content

Commit 92f639f

Browse files
author
Natalie Arellano
committed
Add -daemon to restorer for newer platform
Signed-off-by: Natalie Arellano <narellano@vmware.com>
1 parent 02e0139 commit 92f639f

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

internal/build/lifecycle_execution.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ func (l *LifecycleExecution) Restore(ctx context.Context, buildCache Cache, kani
482482
}
483483
}
484484

485+
flagsOp := WithFlags(flags...)
486+
485487
// for auths
486488
registryOp := NullOp()
487489
if len(registryImages) > 0 {
@@ -492,7 +494,10 @@ func (l *LifecycleExecution) Restore(ctx context.Context, buildCache Cache, kani
492494
registryOp = WithRegistryAccess(authConfig)
493495
}
494496

495-
flagsOp := WithFlags(flags...)
497+
dockerOp := NullOp()
498+
if !l.opts.Publish && l.platformAPI.AtLeast("0.12") {
499+
dockerOp = WithDaemonAccess(l.opts.DockerHost)
500+
}
496501

497502
configProvider := NewPhaseConfigProvider(
498503
"restorer",
@@ -507,10 +512,11 @@ func (l *LifecycleExecution) Restore(ctx context.Context, buildCache Cache, kani
507512
WithNetwork(l.opts.Network),
508513
If(l.hasExtensionsForRun(), WithPostContainerRunOperations(
509514
CopyOutToMaybe(l.mountPaths.cnbDir(), l.tmpDir))), // FIXME: this is hacky; we should get the lifecycle binaries from the lifecycle image
510-
flagsOp,
511515
cacheBindOp,
512-
registryOp,
516+
dockerOp,
517+
flagsOp,
513518
kanikoCacheBindOp,
519+
registryOp,
514520
)
515521

516522
restore := phaseFactory.New(configProvider)

internal/build/lifecycle_execution_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,17 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) {
18381838
})
18391839
})
18401840
})
1841+
1842+
when("publish is false", func() {
1843+
when("platform >= 0.12", func() {
1844+
platformAPI = api.MustParse("0.12")
1845+
1846+
it("configures the phase with daemon access", func() {
1847+
h.AssertEq(t, configProvider.ContainerConfig().User, "root")
1848+
h.AssertSliceContains(t, configProvider.HostConfig().Binds, "/var/run/docker.sock:/var/run/docker.sock")
1849+
})
1850+
})
1851+
})
18411852
})
18421853

18431854
when("#Build", func() {

0 commit comments

Comments
 (0)