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:
@@ -14,15 +14,17 @@ const FilesystemBind = "bind"
|
||||
|
||||
// FSBind represents a host to container bind mount.
|
||||
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"`
|
||||
// host filesystem path to make available to the container
|
||||
Source *container.Absolute `json:"src"`
|
||||
// do not mount filesystem read-only
|
||||
// do not mount Target read-only
|
||||
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"`
|
||||
// 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"`
|
||||
|
||||
// enable special behaviour:
|
||||
@@ -45,6 +47,9 @@ func (b *FSBind) Valid() bool {
|
||||
if b == nil || b.Source == nil {
|
||||
return false
|
||||
}
|
||||
if b.Ensure && b.Optional {
|
||||
return false
|
||||
}
|
||||
if b.Special {
|
||||
if b.Target == nil {
|
||||
return false
|
||||
@@ -94,6 +99,9 @@ func (b *FSBind) Apply(z *ApplyState) {
|
||||
if b.Device {
|
||||
flags |= container.BindDevice | container.BindWritable
|
||||
}
|
||||
if b.Ensure {
|
||||
flags |= container.BindEnsure
|
||||
}
|
||||
if b.Optional {
|
||||
flags |= container.BindOptional
|
||||
}
|
||||
@@ -148,10 +156,15 @@ func (b *FSBind) String() string {
|
||||
expr.Grow(g)
|
||||
expr.WriteString(flagSym)
|
||||
|
||||
if !b.Optional {
|
||||
expr.WriteString("*")
|
||||
} else {
|
||||
switch {
|
||||
case b.Ensure:
|
||||
expr.WriteString("-")
|
||||
|
||||
case b.Optional:
|
||||
expr.WriteString("+")
|
||||
|
||||
default:
|
||||
expr.WriteString("*")
|
||||
}
|
||||
|
||||
expr.WriteString(b.Source.String())
|
||||
|
||||
Reference in New Issue
Block a user