forked from security/hakurei
internal/pkg: automatic overlay mount on work
This directly submits the upperdir to cache. It is primarily used in bootstrapping where tools are limited and should not be used unless there is a very good reason to. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -45,7 +45,7 @@ func TestExec(t *testing.T) {
|
||||
msg,
|
||||
0,
|
||||
nil,
|
||||
check.MustAbs("/work"),
|
||||
pkg.AbsWork,
|
||||
[]string{"HAKUREI_TEST=1"},
|
||||
check.MustAbs("/opt/bin/testtool"),
|
||||
[]string{"testtool"},
|
||||
@@ -71,7 +71,7 @@ func TestExec(t *testing.T) {
|
||||
msg,
|
||||
0,
|
||||
nil,
|
||||
check.MustAbs("/work"),
|
||||
pkg.AbsWork,
|
||||
[]string{"HAKUREI_TEST=1"},
|
||||
check.MustAbs("/opt/bin/testtool"),
|
||||
[]string{"testtool"},
|
||||
@@ -90,7 +90,7 @@ func TestExec(t *testing.T) {
|
||||
msg,
|
||||
0,
|
||||
nil,
|
||||
check.MustAbs("/work"),
|
||||
pkg.AbsWork,
|
||||
[]string{"HAKUREI_TEST=1"},
|
||||
check.MustAbs("/opt/bin/testtool"),
|
||||
[]string{"testtool"},
|
||||
@@ -106,7 +106,7 @@ func TestExec(t *testing.T) {
|
||||
msg,
|
||||
0,
|
||||
nil,
|
||||
check.MustAbs("/work"),
|
||||
pkg.AbsWork,
|
||||
nil,
|
||||
check.MustAbs("/opt/bin/testtool"),
|
||||
[]string{"testtool"},
|
||||
@@ -134,7 +134,7 @@ func TestExec(t *testing.T) {
|
||||
msg,
|
||||
0,
|
||||
&wantChecksum,
|
||||
check.MustAbs("/work"),
|
||||
pkg.AbsWork,
|
||||
[]string{"HAKUREI_TEST=1"},
|
||||
check.MustAbs("/opt/bin/testtool"),
|
||||
[]string{"testtool", "net"},
|
||||
@@ -172,7 +172,7 @@ func TestExec(t *testing.T) {
|
||||
msg,
|
||||
0,
|
||||
nil,
|
||||
check.MustAbs("/work"),
|
||||
pkg.AbsWork,
|
||||
[]string{"HAKUREI_TEST=1", "HAKUREI_ROOT=1"},
|
||||
check.MustAbs("/opt/bin/testtool"),
|
||||
[]string{"testtool"},
|
||||
@@ -204,7 +204,7 @@ func TestExec(t *testing.T) {
|
||||
msg,
|
||||
0,
|
||||
nil,
|
||||
check.MustAbs("/work"),
|
||||
pkg.AbsWork,
|
||||
[]string{"HAKUREI_TEST=1", "HAKUREI_ROOT=1"},
|
||||
check.MustAbs("/tmp/bin/testtool"),
|
||||
[]string{"testtool"},
|
||||
@@ -232,6 +232,48 @@ func TestExec(t *testing.T) {
|
||||
|
||||
testtoolDestroy(t, base, c)
|
||||
}, pkg.MustDecode("_r1IBeMWCkLwQ9Im9w0tV9_CWIOfQlXkkP2CogPHLmZp_AB6W3_8HVZqDV00dNAm")},
|
||||
|
||||
{"overlay work", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) {
|
||||
c.SetStrict(true)
|
||||
testtool, testtoolDestroy := newTesttool()
|
||||
|
||||
msg := message.New(log.New(os.Stderr, "container: ", 0))
|
||||
msg.SwapVerbose(testing.Verbose())
|
||||
|
||||
cureMany(t, c, []cureStep{
|
||||
{"container", pkg.NewExec(
|
||||
t.Context(),
|
||||
msg,
|
||||
0,
|
||||
nil,
|
||||
pkg.AbsWork,
|
||||
[]string{"HAKUREI_TEST=1", "HAKUREI_ROOT=1"},
|
||||
check.MustAbs("/work/bin/testtool"),
|
||||
[]string{"testtool"},
|
||||
|
||||
pkg.MustPath("/", stubArtifact{
|
||||
kind: pkg.KindTar,
|
||||
params: []byte("empty directory"),
|
||||
cure: func(c *pkg.CureContext) error {
|
||||
return os.MkdirAll(c.GetWorkDir().String(), 0700)
|
||||
},
|
||||
}),
|
||||
pkg.MustPath("/work/", stubArtifact{
|
||||
kind: pkg.KindTar,
|
||||
params: []byte("empty directory"),
|
||||
cure: func(c *pkg.CureContext) error {
|
||||
return os.MkdirAll(c.GetWorkDir().String(), 0700)
|
||||
},
|
||||
}),
|
||||
pkg.ExecContainerPath{
|
||||
P: pkg.AbsWork,
|
||||
A: testtool,
|
||||
},
|
||||
), ignorePathname, wantChecksumOffline, nil},
|
||||
})
|
||||
|
||||
testtoolDestroy(t, base, c)
|
||||
}, pkg.MustDecode("-DrfvuB9gUAT-Tgw6V1KjFyosYGMGKJW7KMZFF1Ew8jZ9LJ82FtXf0wTgM3fO0oD")},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user