forked from opencontainers/runc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspec.go
More file actions
119 lines (110 loc) · 2.47 KB
/
Copy pathspec.go
File metadata and controls
119 lines (110 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package main
import (
"encoding/json"
"fmt"
"runtime"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
)
const cpuQuotaMultiplyer = 100000
type Mount struct {
Type string `json:"type"`
Source string `json:"source"`
Destination string `json:"destination"`
Options string `json:"options"`
}
type Process struct {
Terminal bool `json:"terminal"`
User string `json:"user"`
Args []string `json:"args"`
Env []string `json:"env"`
Cwd string `json:"cwd"`
}
type Root struct {
Path string `json:"path"`
Readonly bool `json:"readonly"`
}
type Platform struct {
OS string `json:"os"`
Arch string `json:"arch"`
}
type PortableSpec struct {
Version string `json:"version"`
Platform Platform `json:"platform"`
Process Process `json:"process"`
Root Root `json:"root"`
Hostname string `json:"hostname"`
Mounts []Mount `json:"mounts"`
}
var specCommand = cli.Command{
Name: "spec",
Usage: "create a new specification file",
Action: func(context *cli.Context) {
spec := PortableSpec{
Version: version,
Platform: Platform{
OS: runtime.GOOS,
Arch: runtime.GOARCH,
},
Root: Root{
Path: "rootfs",
Readonly: true,
},
Process: Process{
Terminal: true,
User: "daemon",
Args: []string{
"sh",
},
Env: []string{
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TERM=xterm",
},
},
Hostname: "shell",
Mounts: []Mount{
{
Type: "proc",
Source: "proc",
Destination: "/proc",
Options: "",
},
{
Type: "tmpfs",
Source: "tmpfs",
Destination: "/dev",
Options: "nosuid,strictatime,mode=755,size=65536k",
},
{
Type: "devpts",
Source: "devpts",
Destination: "/dev/pts",
Options: "nosuid,noexec,newinstance,ptmxmode=0666,mode=0620,gid=5",
},
{
Type: "tmpfs",
Source: "shm",
Destination: "/dev/shm",
Options: "nosuid,noexec,nodev,mode=1777,size=65536k",
},
{
Type: "mqueue",
Source: "mqueue",
Destination: "/dev/mqueue",
Options: "nosuid,noexec,nodev",
},
{
Type: "sysfs",
Source: "sysfs",
Destination: "/sys",
Options: "nosuid,noexec,nodev",
},
},
}
data, err := json.MarshalIndent(&spec, "", "\t")
if err != nil {
logrus.Fatal(err)
}
fmt.Printf("%s", data)
},
}