hst/fsbind: optional ensure source
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m18s
Test / Hakurei (push) Successful in 3m22s
Test / Hpkg (push) Successful in 4m17s
Test / Sandbox (race detector) (push) Successful in 5m33s
Test / Hakurei (race detector) (push) Successful in 3m1s
Test / Flake checks (push) Successful in 1m29s
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m18s
Test / Hakurei (push) Successful in 3m22s
Test / Hpkg (push) Successful in 4m17s
Test / Sandbox (race detector) (push) Successful in 5m33s
Test / Hakurei (race detector) (push) Successful in 3m1s
Test / Flake checks (push) Successful in 1m29s
This exposes the BindEnsure flag of BindMountOp. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
2e0a4795f6
commit
878b66022e
@ -53,7 +53,7 @@ Filesystem
|
|||||||
*/nix/store
|
*/nix/store
|
||||||
/run/current-system@
|
/run/current-system@
|
||||||
/run/opengl-driver@
|
/run/opengl-driver@
|
||||||
w*/var/lib/hakurei/u0/org.chromium.Chromium:/data/data/org.chromium.Chromium
|
w-/var/lib/hakurei/u0/org.chromium.Chromium:/data/data/org.chromium.Chromium
|
||||||
d+/dev/dri
|
d+/dev/dri
|
||||||
|
|
||||||
Extra ACL
|
Extra ACL
|
||||||
@ -130,7 +130,7 @@ Filesystem
|
|||||||
*/nix/store
|
*/nix/store
|
||||||
/run/current-system@
|
/run/current-system@
|
||||||
/run/opengl-driver@
|
/run/opengl-driver@
|
||||||
w*/var/lib/hakurei/u0/org.chromium.Chromium:/data/data/org.chromium.Chromium
|
w-/var/lib/hakurei/u0/org.chromium.Chromium:/data/data/org.chromium.Chromium
|
||||||
d+/dev/dri
|
d+/dev/dri
|
||||||
|
|
||||||
Extra ACL
|
Extra ACL
|
||||||
@ -325,7 +325,8 @@ App
|
|||||||
"type": "bind",
|
"type": "bind",
|
||||||
"dst": "/data/data/org.chromium.Chromium",
|
"dst": "/data/data/org.chromium.Chromium",
|
||||||
"src": "/var/lib/hakurei/u0/org.chromium.Chromium",
|
"src": "/var/lib/hakurei/u0/org.chromium.Chromium",
|
||||||
"write": true
|
"write": true,
|
||||||
|
"ensure": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "bind",
|
"type": "bind",
|
||||||
@ -481,7 +482,8 @@ App
|
|||||||
"type": "bind",
|
"type": "bind",
|
||||||
"dst": "/data/data/org.chromium.Chromium",
|
"dst": "/data/data/org.chromium.Chromium",
|
||||||
"src": "/var/lib/hakurei/u0/org.chromium.Chromium",
|
"src": "/var/lib/hakurei/u0/org.chromium.Chromium",
|
||||||
"write": true
|
"write": true,
|
||||||
|
"ensure": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "bind",
|
"type": "bind",
|
||||||
@ -691,7 +693,8 @@ func Test_printPs(t *testing.T) {
|
|||||||
"type": "bind",
|
"type": "bind",
|
||||||
"dst": "/data/data/org.chromium.Chromium",
|
"dst": "/data/data/org.chromium.Chromium",
|
||||||
"src": "/var/lib/hakurei/u0/org.chromium.Chromium",
|
"src": "/var/lib/hakurei/u0/org.chromium.Chromium",
|
||||||
"write": true
|
"write": true,
|
||||||
|
"ensure": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "bind",
|
"type": "bind",
|
||||||
|
@ -14,15 +14,17 @@ const FilesystemBind = "bind"
|
|||||||
|
|
||||||
// FSBind represents a host to container bind mount.
|
// FSBind represents a host to container bind mount.
|
||||||
type FSBind struct {
|
type FSBind struct {
|
||||||
// mount point in container, same as src if empty
|
// mount point in container, same as Source if empty
|
||||||
Target *container.Absolute `json:"dst,omitempty"`
|
Target *container.Absolute `json:"dst,omitempty"`
|
||||||
// host filesystem path to make available to the container
|
// host filesystem path to make available to the container
|
||||||
Source *container.Absolute `json:"src"`
|
Source *container.Absolute `json:"src"`
|
||||||
// do not mount filesystem read-only
|
// do not mount Target read-only
|
||||||
Write bool `json:"write,omitempty"`
|
Write bool `json:"write,omitempty"`
|
||||||
// do not disable device files, implies Write
|
// do not disable device files on Target, implies Write
|
||||||
Device bool `json:"dev,omitempty"`
|
Device bool `json:"dev,omitempty"`
|
||||||
// skip this mount point if the host path does not exist
|
// create Source as a directory if it does not exist
|
||||||
|
Ensure bool `json:"ensure,omitempty"`
|
||||||
|
// skip this mount point if Source does not exist
|
||||||
Optional bool `json:"optional,omitempty"`
|
Optional bool `json:"optional,omitempty"`
|
||||||
|
|
||||||
// enable special behaviour:
|
// enable special behaviour:
|
||||||
@ -45,6 +47,9 @@ func (b *FSBind) Valid() bool {
|
|||||||
if b == nil || b.Source == nil {
|
if b == nil || b.Source == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if b.Ensure && b.Optional {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if b.Special {
|
if b.Special {
|
||||||
if b.Target == nil {
|
if b.Target == nil {
|
||||||
return false
|
return false
|
||||||
@ -94,6 +99,9 @@ func (b *FSBind) Apply(z *ApplyState) {
|
|||||||
if b.Device {
|
if b.Device {
|
||||||
flags |= container.BindDevice | container.BindWritable
|
flags |= container.BindDevice | container.BindWritable
|
||||||
}
|
}
|
||||||
|
if b.Ensure {
|
||||||
|
flags |= container.BindEnsure
|
||||||
|
}
|
||||||
if b.Optional {
|
if b.Optional {
|
||||||
flags |= container.BindOptional
|
flags |= container.BindOptional
|
||||||
}
|
}
|
||||||
@ -148,10 +156,15 @@ func (b *FSBind) String() string {
|
|||||||
expr.Grow(g)
|
expr.Grow(g)
|
||||||
expr.WriteString(flagSym)
|
expr.WriteString(flagSym)
|
||||||
|
|
||||||
if !b.Optional {
|
switch {
|
||||||
expr.WriteString("*")
|
case b.Ensure:
|
||||||
} else {
|
expr.WriteString("-")
|
||||||
|
|
||||||
|
case b.Optional:
|
||||||
expr.WriteString("+")
|
expr.WriteString("+")
|
||||||
|
|
||||||
|
default:
|
||||||
|
expr.WriteString("*")
|
||||||
}
|
}
|
||||||
|
|
||||||
expr.WriteString(b.Source.String())
|
expr.WriteString(b.Source.String())
|
||||||
|
@ -10,6 +10,8 @@ import (
|
|||||||
func TestFSBind(t *testing.T) {
|
func TestFSBind(t *testing.T) {
|
||||||
checkFs(t, []fsTestCase{
|
checkFs(t, []fsTestCase{
|
||||||
{"nil", (*hst.FSBind)(nil), false, nil, nil, nil, "<invalid>"},
|
{"nil", (*hst.FSBind)(nil), false, nil, nil, nil, "<invalid>"},
|
||||||
|
{"ensure optional", &hst.FSBind{Source: m("/"), Ensure: true, Optional: true},
|
||||||
|
false, nil, nil, nil, "<invalid>"},
|
||||||
|
|
||||||
{"full", &hst.FSBind{
|
{"full", &hst.FSBind{
|
||||||
Target: m("/dev"),
|
Target: m("/dev"),
|
||||||
@ -23,6 +25,18 @@ func TestFSBind(t *testing.T) {
|
|||||||
}}, m("/dev"), ms("/mnt/dev"),
|
}}, m("/dev"), ms("/mnt/dev"),
|
||||||
"d+/mnt/dev:/dev"},
|
"d+/mnt/dev:/dev"},
|
||||||
|
|
||||||
|
{"full ensure", &hst.FSBind{
|
||||||
|
Target: m("/dev"),
|
||||||
|
Source: m("/mnt/dev"),
|
||||||
|
Ensure: true,
|
||||||
|
Device: true,
|
||||||
|
}, true, container.Ops{&container.BindMountOp{
|
||||||
|
Source: m("/mnt/dev"),
|
||||||
|
Target: m("/dev"),
|
||||||
|
Flags: container.BindWritable | container.BindDevice | container.BindEnsure,
|
||||||
|
}}, m("/dev"), ms("/mnt/dev"),
|
||||||
|
"d-/mnt/dev:/dev"},
|
||||||
|
|
||||||
{"full write dev", &hst.FSBind{
|
{"full write dev", &hst.FSBind{
|
||||||
Target: m("/dev"),
|
Target: m("/dev"),
|
||||||
Source: m("/mnt/dev"),
|
Source: m("/mnt/dev"),
|
||||||
|
@ -97,8 +97,8 @@ func Template() *Config {
|
|||||||
"GOOGLE_DEFAULT_CLIENT_SECRET": "OTJgUOQcT7lO7GsGZq2G4IlT",
|
"GOOGLE_DEFAULT_CLIENT_SECRET": "OTJgUOQcT7lO7GsGZq2G4IlT",
|
||||||
},
|
},
|
||||||
Filesystem: []FilesystemConfigJSON{
|
Filesystem: []FilesystemConfigJSON{
|
||||||
{&FSBind{container.AbsFHSRoot, container.AbsFHSVarLib.Append("hakurei/base/org.debian"), true, false, false, true}},
|
{&FSBind{Target: container.AbsFHSRoot, Source: container.AbsFHSVarLib.Append("hakurei/base/org.debian"), Write: true, Special: true}},
|
||||||
{&FSBind{container.AbsFHSEtc, container.AbsFHSEtc, false, false, false, true}},
|
{&FSBind{Target: container.AbsFHSEtc, Source: container.AbsFHSEtc, Special: true}},
|
||||||
{&FSEphemeral{Target: container.AbsFHSTmp, Write: true, Perm: 0755}},
|
{&FSEphemeral{Target: container.AbsFHSTmp, Write: true, Perm: 0755}},
|
||||||
{&FSOverlay{
|
{&FSOverlay{
|
||||||
Target: container.MustAbs("/nix/store"),
|
Target: container.MustAbs("/nix/store"),
|
||||||
@ -110,7 +110,7 @@ func Template() *Config {
|
|||||||
{&FSLink{Target: container.AbsFHSRun.Append("current-system"), Linkname: "/run/current-system", Dereference: true}},
|
{&FSLink{Target: container.AbsFHSRun.Append("current-system"), Linkname: "/run/current-system", Dereference: true}},
|
||||||
{&FSLink{Target: container.AbsFHSRun.Append("opengl-driver"), Linkname: "/run/opengl-driver", Dereference: true}},
|
{&FSLink{Target: container.AbsFHSRun.Append("opengl-driver"), Linkname: "/run/opengl-driver", Dereference: true}},
|
||||||
{&FSBind{Source: container.AbsFHSVarLib.Append("hakurei/u0/org.chromium.Chromium"),
|
{&FSBind{Source: container.AbsFHSVarLib.Append("hakurei/u0/org.chromium.Chromium"),
|
||||||
Target: container.MustAbs("/data/data/org.chromium.Chromium"), Write: true}},
|
Target: container.MustAbs("/data/data/org.chromium.Chromium"), Write: true, Ensure: true}},
|
||||||
{&FSBind{Source: container.AbsFHSDev.Append("dri"), Device: true, Optional: true}},
|
{&FSBind{Source: container.AbsFHSDev.Append("dri"), Device: true, Optional: true}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -150,7 +150,8 @@ func TestTemplate(t *testing.T) {
|
|||||||
"type": "bind",
|
"type": "bind",
|
||||||
"dst": "/data/data/org.chromium.Chromium",
|
"dst": "/data/data/org.chromium.Chromium",
|
||||||
"src": "/var/lib/hakurei/u0/org.chromium.Chromium",
|
"src": "/var/lib/hakurei/u0/org.chromium.Chromium",
|
||||||
"write": true
|
"write": true,
|
||||||
|
"ensure": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "bind",
|
"type": "bind",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user