Debian Codegraph @

options.go

raw symbols SCIP
1 // Copyright © 2013, 2014, The Go-LXC Authors. All rights reserved.
2 // Use of this source code is governed by a LGPLv2.1
3 // license that can be found in the LICENSE file.
4
5 //go:build linux && cgo
6 // +build linux,cgo
7
8 package lxc
9
10 import (
11 "os"
12 )
13
14 // AttachOptions type is used for defining various attach options.
15 type AttachOptions struct {
16
17 // Specify the namespaces to attach to, as OR'ed list of clone flags (syscall.CLONE_NEWNS | syscall.CLONE_NEWUTS ...).
18 Namespaces int
19
20 // Specify the architecture which the kernel should appear to be running as to the command executed.
21 Arch Personality
22
23 // Cwd specifies the working directory of the command.
24 Cwd string
25
26 // UID specifies the user id to run as.
27 UID int
28
29 // GID specifies the group id to run as.
30 GID int
31
32 // Groups specifies the list of additional group ids to run with.
33 Groups []int
34
35 // If ClearEnv is true the environment is cleared before running the command.
36 ClearEnv bool
37
38 // Env specifies the environment of the process.
39 Env []string
40
41 // EnvToKeep specifies the environment of the process when ClearEnv is true.
42 EnvToKeep []string
43
44 // StdinFd specifies the fd to read input from.
45 StdinFd uintptr
46
47 // StdoutFd specifies the fd to write output to.
48 StdoutFd uintptr
49
50 // StderrFd specifies the fd to write error output to.
51 StderrFd uintptr
52
53 // RemountSysProc remounts /sys and /proc for the executed command.
54 // This is required to reflect the container (PID) namespace context
55 // if the command does not attach to the container's mount namespace.
56 RemountSysProc bool
57
58 // ElevatedPrivileges runs the command with elevated privileges.
59 // The capabilities, cgroup and security module restrictions of the container are not applied.
60 // WARNING: This may leak privileges into the container.
61 ElevatedPrivileges bool
62 }
63
64 // DefaultAttachOptions is a convenient set of options to be used.
65 var DefaultAttachOptions = AttachOptions{
66 Namespaces: -1,
67 Arch: -1,
68 Cwd: "/",
69 UID: -1,
70 GID: -1,
71 Groups: nil,
72 ClearEnv: false,
73 Env: nil,
74 EnvToKeep: nil,
75 StdinFd: os.Stdin.Fd(),
76 StdoutFd: os.Stdout.Fd(),
77 StderrFd: os.Stderr.Fd(),
78 RemountSysProc: false,
79 ElevatedPrivileges: false,
80 }
81
82 // TemplateOptions type is used for defining various template options.
83 type TemplateOptions struct {
84
85 // Template specifies the name of the template.
86 Template string
87
88 // Backend specifies the type of the backend.
89 Backend BackendStore
90
91 BackendSpecs *BackendStoreSpecs
92
93 // Distro specifies the name of the distribution.
94 Distro string
95
96 // Release specifies the name/version of the distribution.
97 Release string
98
99 // Arch specified the architecture of the container.
100 Arch string
101
102 // Variant specifies the variant of the image (default: "default").
103 Variant string
104
105 // Image server (default: "images.linuxcontainers.org").
106 Server string
107
108 // GPG keyid (default: 0x...).
109 KeyID string
110
111 // GPG keyserver to use.
112 KeyServer string
113
114 // Disable GPG validation (not recommended).
115 DisableGPGValidation bool
116
117 // Flush the local copy (if present).
118 FlushCache bool
119
120 // Force the use of the local copy even if expired.
121 ForceCache bool
122
123 // ExtraArgs provides a way to specify template specific args.
124 ExtraArgs []string
125 }
126
127 // BackendStoreSpecs represents a LXC storage backend.
128 type BackendStoreSpecs struct {
129 FSType string
130 FSSize uint64
131 Dir *string
132 ZFS struct {
133 Root string
134 }
135 LVM struct {
136 VG, LV, Thinpool string
137 }
138 RBD struct {
139 Name, Pool string
140 }
141 }
142
143 // DownloadTemplateOptions is a convenient set of options for "download" template.
144 var DownloadTemplateOptions = TemplateOptions{
145 Template: "download",
146 Distro: "ubuntu",
147 Release: "trusty",
148 Arch: "amd64",
149 }
150
151 // BusyboxTemplateOptions is a convenient set of options for "busybox" template.
152 var BusyboxTemplateOptions = TemplateOptions{
153 Template: "busybox",
154 }
155
156 // UbuntuTemplateOptions is a convenient set of options for "ubuntu" template.
157 var UbuntuTemplateOptions = TemplateOptions{
158 Template: "ubuntu",
159 }
160
161 // ConsoleOptions type is used for defining various console options.
162 type ConsoleOptions struct {
163
164 // Tty number to attempt to allocate, -1 to allocate the first available tty, or 0 to allocate the console.
165 Tty int
166
167 // StdinFd specifies the fd to read input from.
168 StdinFd uintptr
169
170 // StdoutFd specifies the fd to write output to.
171 StdoutFd uintptr
172
173 // StderrFd specifies the fd to write error output to.
174 StderrFd uintptr
175
176 // EscapeCharacter (a means <Ctrl a>, b maens <Ctrl b>).
177 EscapeCharacter rune
178 }
179
180 // DefaultConsoleOptions is a convenient set of options to be used.
181 var DefaultConsoleOptions = ConsoleOptions{
182 Tty: -1,
183 StdinFd: os.Stdin.Fd(),
184 StdoutFd: os.Stdout.Fd(),
185 StderrFd: os.Stderr.Fd(),
186 EscapeCharacter: 'a',
187 }
188
189 // CloneOptions type is used for defining various clone options.
190 type CloneOptions struct {
191
192 // Backend specifies the type of the backend.
193 Backend BackendStore
194
195 // lxcpath in which to create the new container. If not set the original container's lxcpath will be used.
196 ConfigPath string
197
198 // Do not change the hostname of the container (in the root filesystem).
199 KeepName bool
200
201 // Use the same MAC address as the original container, rather than generating a new random one.
202 KeepMAC bool
203
204 // Create a snapshot rather than copy.
205 Snapshot bool
206 }
207
208 // DefaultCloneOptions is a convenient set of options to be used.
209 var DefaultCloneOptions = CloneOptions{
210 Backend: Directory,
211 }
212
213 // CheckpointOptions type is used for defining checkpoint options for CRIU.
214 type CheckpointOptions struct {
215 Directory string
216 Stop bool
217 Verbose bool
218 }
219
220 // RestoreOptions type is used for defining restore options for CRIU.
221 type RestoreOptions struct {
222 Directory string
223 Verbose bool
224 }
225
226 // MigrateOptions type is used for defining migrate options.
227 type MigrateOptions struct {
228 Directory string
229 PredumpDir string
230 ActionScript string
231 Verbose bool
232 Stop bool
233 PreservesInodes bool
234 GhostLimit uint64
235 FeaturesToCheck CriuFeatures
236 }
237
238 // ConsoleLogOptions type is used for defining console log options.
239 type ConsoleLogOptions struct {
240 ClearLog bool
241 ReadLog bool
242 ReadMax uint64
243 WriteToLogFile bool
244 }