internal/pkg: automatic overlay mount on tmp
All checks were successful
Test / Create distribution (push) Successful in 52s
Test / Sandbox (push) Successful in 2m54s
Test / ShareFS (push) Successful in 4m46s
Test / Sandbox (race detector) (push) Successful in 5m20s
Test / Hakurei (push) Successful in 5m35s
Test / Hpkg (push) Successful in 5m34s
Test / Hakurei (race detector) (push) Successful in 7m37s
Test / Flake checks (push) Successful in 1m48s

This sets up the last Artifact to target /tmp as a writable overlay mount backed by the host side temp directory. This is useful for an Artifact containing source code to be built for another Artifact for example.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-06 23:34:43 +09:00
parent aa0a949cef
commit 0df87ab111
4 changed files with 139 additions and 12 deletions

View File

@@ -39,11 +39,19 @@ func main() {
if !slices.Equal(wantEnv, os.Environ()) {
log.Fatalf("Environ: %q, want %q", os.Environ(), wantEnv)
}
const wantExec = "/opt/bin/testtool"
var overlayTmp bool
const (
wantExec = "/opt/bin/testtool"
wantExecOverlay = "/tmp/bin/testtool"
)
if got, err := os.Executable(); err != nil {
log.Fatalf("Executable: error = %v", err)
} else if got != wantExec {
log.Fatalf("Executable: %q, want %q", got, wantExec)
if got != wantExecOverlay {
log.Fatalf("Executable: %q, want %q", got, wantExec)
}
overlayTmp = true
}
wantHostname := "cure"
@@ -105,7 +113,6 @@ func main() {
if path.Base(lowerdir) != checksumEmptyDir {
log.Fatal("unexpected artifact checksum")
}
} else {
if hostNet {
ident = "I3T53NtN6HPAyyodHtq2B0clcsoS1nPdvCEb-Zc5K-hoqFGL2od1mftHhwG7gX1S"
@@ -126,7 +133,16 @@ func main() {
}
}
next() // testtool artifact
if !overlayTmp {
next() // testtool artifact
} else {
ident = "3ELJ8l42g6XeIoLGR9LheVhMIwSIleD6VrhsliBuon5DAdBOwFSMqd7aiUI4fll7"
next()
if path.Base(m.Root) != checksumEmptyDir || m.Target != "/tmp" {
log.Fatal("unexpected artifact checksum")
}
}
next()
if path.Base(m.Root) != ident || m.Target != "/work" {
@@ -134,8 +150,16 @@ func main() {
}
next()
if path.Base(m.Root) != ident || m.Target != "/tmp" {
log.Fatal("unexpected temp mount entry")
if !overlayTmp {
if path.Base(m.Root) != ident || m.Target != "/tmp" {
log.Fatal("unexpected temp mount entry")
}
} else {
// testtool artifact
if m.Root != "/" || m.Target != "/tmp" ||
m.Source != "overlay" || m.FsType != "overlay" {
log.Fatal("unexpected temp mount entry")
}
}
next()