aboutsummaryrefslogtreecommitdiffhomepage
path: root/hst/fsbind.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-26 00:50:23 +0900
committerOphestra <cat@gensokyo.uk>2025-08-26 00:50:23 +0900
commit878b66022e7573ca89fd1fbc266133c7776a98dd (patch)
tree006ff7de65f9ab291186088d7eb3c9e9745b1a43 /hst/fsbind.go
parent2e0a4795f6a0016832d8fc51884abce4d01a8a58 (diff)
hst/fsbind: optional ensure source
This exposes the BindEnsure flag of BindMountOp. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'hst/fsbind.go')
-rw-r--r--hst/fsbind.go27
1 files changed, 20 insertions, 7 deletions
diff --git a/hst/fsbind.go b/hst/fsbind.go
index 7aa273c5..3769fcd9 100644
--- a/hst/fsbind.go
+++ b/hst/fsbind.go
@@ -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())