helper/bwrap: expose address of DataConfig
All checks were successful
Test / Create distribution (push) Successful in 24s
Test / Run NixOS test (push) Successful in 2m7s

This allows the caller to defer fulfilling its payload.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-02-16 12:33:59 +09:00
parent c667b13a00
commit 1fa5e992e4
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q

View File

@ -78,11 +78,22 @@ CopyBind(dest, payload, true) copy from FD to file which is bind-mounted on DEST
(--bind-data FD DEST) (--bind-data FD DEST)
*/ */
func (c *Config) CopyBind(dest string, payload []byte, opts ...bool) *Config { 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 t := DataROBind
if len(opts) > 0 && opts[0] { if len(opts) > 0 && opts[0] {
t = DataBind 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 return c
} }