diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-02-16 12:33:59 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-02-16 12:33:59 +0900 |
| commit | 1fa5e992e4e73fd6f1774544e07655b88f9c83d6 (patch) | |
| tree | 9373461ed3613794aa6dd6b1b8dd73052f0fa555 /helper | |
| parent | c667b13a00bd2995751640322a94b81c2f7f4d6d (diff) | |
helper/bwrap: expose address of DataConfig
This allows the caller to defer fulfilling its payload.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'helper')
| -rw-r--r-- | helper/bwrap/builder.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/helper/bwrap/builder.go b/helper/bwrap/builder.go index d196bc06..e6685aa9 100644 --- a/helper/bwrap/builder.go +++ b/helper/bwrap/builder.go @@ -78,11 +78,22 @@ CopyBind(dest, payload, true) copy from FD to file which is bind-mounted on DEST (--bind-data FD DEST) */ func (c *Config) CopyBind(dest string, payload []byte, opts ...bool) *Config { + var p *[]byte + c.CopyBindRef(dest, &p, opts...) + *p = payload + return c +} + +// CopyBindRef is the same as CopyBind but writes the address of DataConfig.Data. +func (c *Config) CopyBindRef(dest string, payloadRef **[]byte, opts ...bool) *Config { t := DataROBind if len(opts) > 0 && opts[0] { t = DataBind } - c.Filesystem = append(c.Filesystem, &DataConfig{Dest: dest, Data: payload, Type: t}) + d := &DataConfig{Dest: dest, Type: t} + *payloadRef = &d.Data + + c.Filesystem = append(c.Filesystem, d) return c } |
