aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/bwrap/arg.static.int.go
diff options
context:
space:
mode:
Diffstat (limited to 'helper/bwrap/arg.static.int.go')
-rw-r--r--helper/bwrap/arg.static.int.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/helper/bwrap/arg.static.int.go b/helper/bwrap/arg.static.int.go
new file mode 100644
index 00000000..cba3b1f7
--- /dev/null
+++ b/helper/bwrap/arg.static.int.go
@@ -0,0 +1,47 @@
+package bwrap
+
+import "strconv"
+
+const (
+ UID = iota
+ GID
+ Perms
+ Size
+)
+
+var intArgs = [...]string{
+ UID: "--uid",
+ GID: "--gid",
+ Perms: "--perms",
+ Size: "--size",
+}
+
+func (c *Config) intArgs() Builder {
+ // Arg types:
+ // Perms
+ // are handled by the sequential builder
+
+ return &intArg{
+ UID: c.UID,
+ GID: c.GID,
+ }
+}
+
+type intArg [len(intArgs)]*int
+
+func (n *intArg) Len() (l int) {
+ for _, v := range n {
+ if v != nil {
+ l += 2
+ }
+ }
+ return
+}
+
+func (n *intArg) Append(args *[]string) {
+ for i, v := range n {
+ if v != nil {
+ *args = append(*args, intArgs[i], strconv.Itoa(*v))
+ }
+ }
+}