aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/bwrap/config.pair.go
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-10-07 14:40:35 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-10-07 14:40:35 +0900
commit6a2802cf309fb9758756c56ef05c9354d9cb9003 (patch)
treed1efa27407aa3a2e1337fa4ffafa3df9fd677ec4 /helper/bwrap/config.pair.go
parent0fb9e401912f89d25ff96b0dd36aabf43b4fab8f (diff)
helper: move bwrap into helper
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'helper/bwrap/config.pair.go')
-rw-r--r--helper/bwrap/config.pair.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/helper/bwrap/config.pair.go b/helper/bwrap/config.pair.go
new file mode 100644
index 00000000..b0b1001b
--- /dev/null
+++ b/helper/bwrap/config.pair.go
@@ -0,0 +1,54 @@
+package bwrap
+
+import "strconv"
+
+const (
+ SetEnv = iota
+
+ Bind
+ BindTry
+ DevBind
+ DevBindTry
+ ROBind
+ ROBindTry
+
+ Chmod
+
+ pairC
+)
+
+var pairArgs = func() (n [pairC]string) {
+ n[SetEnv] = "--setenv"
+
+ n[Bind] = "--bind"
+ n[BindTry] = "--bind-try"
+ n[DevBind] = "--dev-bind"
+ n[DevBindTry] = "--dev-bind-try"
+ n[ROBind] = "--ro-bind"
+ n[ROBindTry] = "--ro-bind-try"
+
+ n[Chmod] = "--chmod"
+
+ return
+}()
+
+func (c *Config) pairArgs() (n [pairC][][2]string) {
+ n[SetEnv] = make([][2]string, 0, len(c.SetEnv))
+ for k, v := range c.SetEnv {
+ n[SetEnv] = append(n[SetEnv], [2]string{k, v})
+ }
+
+ n[Bind] = c.Bind
+ n[BindTry] = c.BindTry
+ n[DevBind] = c.DevBind
+ n[DevBindTry] = c.DevBindTry
+ n[ROBind] = c.ROBind
+ n[ROBindTry] = c.ROBindTry
+
+ n[Chmod] = make([][2]string, 0, len(c.Chmod))
+ for path, octal := range c.Chmod {
+ n[Chmod] = append(n[Chmod], [2]string{strconv.Itoa(int(octal)), path})
+ }
+
+ return
+}