-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathflags.go
356 lines (300 loc) · 10.7 KB
/
flags.go
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
// Copyright 2015 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
// Author: Nathan VanBenschoten ([email protected])
package cliflags
// FlagInfo contains the static information for a CLI flag.
type FlagInfo struct {
// Name of the flag as used on the command line.
Name string
// Shorthand is the short form of the flag (optional).
Shorthand string
// EnvVar is the name of the environment variable through which the flag value
// can be controlled (optional).
EnvVar string
// Description of the flag.
//
// The text will be automatically re-wrapped. The wrapping can be stopped by
// embedding the tag "<PRE>": this tag is removed from the text and
// signals that everything that follows should not be re-wrapped. To start
// wrapping again, use "</PRE>".
Description string
}
// Attrs and others store the static information for CLI flags.
var (
Attrs = FlagInfo{
Name: "attrs",
Description: `
An ordered, colon-separated list of node attributes. Attributes are arbitrary
strings specifying machine capabilities. Machine capabilities might include
specialized hardware or number of cores (e.g. "gpu", "x16c"). For example:
<PRE>
--attrs=x16c:gpu`,
}
Locality = FlagInfo{
Name: "locality",
Description: `
An ordered, comma-separated list of key-value pairs that describe the topography
of the machine. Topography might include country, datacenter or rack
designations. Data is automatically replicated to maximize diversities of each
tier. The order of tiers is used to determine the priority of the diversity. The
tiers and order must be the same on all nodes. For example:
<PRE>
--locality=country=us,region=us-west,datacenter=us-west-1b,rack=12`,
}
ZoneConfig = FlagInfo{
Name: "file",
Shorthand: "f",
Description: `
File to read the zone configuration from. Specify "-" to read from standard input.`,
}
Background = FlagInfo{
Name: "background",
Description: `
Start the server in the background. This is similar to appending "&"
to the command line, but when the server is started with --background,
control is not returned to the shell until the server is ready to
accept requests.`,
}
Cache = FlagInfo{
Name: "cache",
Description: `
Total size in bytes for caches, shared evenly if there are multiple
storage devices. Size suffixes are supported (e.g. 1GB and 1GiB).
If left unspecified, defaults to 25% of the physical memory, or
512MB if the memory size cannot be determined.`,
}
ClientHost = FlagInfo{
Name: "host",
EnvVar: "COCKROACH_HOST",
Description: `Database server host to connect to.`,
}
ClientPort = FlagInfo{
Name: "port",
Shorthand: "p",
EnvVar: "COCKROACH_PORT",
Description: `Database server port to connect to.`,
}
Database = FlagInfo{
Name: "database",
Shorthand: "d",
EnvVar: "COCKROACH_DATABASE",
Description: `The name of the database to connect to.`,
}
Deps = FlagInfo{
Name: "deps",
Description: `Include dependency versions`,
}
Execute = FlagInfo{
Name: "execute",
Shorthand: "e",
Description: `
Execute the SQL statement(s) on the command line, then exit. This flag may be
specified multiple times and each value may contain multiple semicolon
separated statements. If an error occurs in any statement, the command exits
with a non-zero status code and further statements are not executed. The
results of each SQL statement are printed on the standard output.`,
}
Pretty = FlagInfo{
Name: "pretty",
Description: `
Causes table rows to be formatted as tables using ASCII art.
When not specified, table rows are printed as tab-separated values (TSV).`,
}
Join = FlagInfo{
Name: "join",
Shorthand: "j",
Description: `
The address of node which acts as bootstrap when a new node is
joining an existing cluster. This flag can be specified
separately for each address, for example:
<PRE>
--join=localhost:1234 --join=localhost:2345
</PRE>
Or can be specified as a comma separated list in single flag,
or both forms can be used together, for example:
<PRE>
--join=localhost:1234,localhost:2345 --join=localhost:3456
</PRE>
Each address in the list has an optional type: [type=]<address>.
An unspecified type means ip address or dns. Type is one of:
<PRE>
- tcp: (default if type is omitted): plain ip address or hostname.
- http-lb: HTTP load balancer: we query
http(s)://<address>/_status/details/local`,
}
ServerHost = FlagInfo{
Name: "host",
Description: `
The address to listen on. The node will also advertise itself using this
hostname; it must resolve from other nodes in the cluster.`,
}
ServerPort = FlagInfo{
Name: "port",
Shorthand: "p",
Description: `The port to bind to.`,
}
ServerHTTPPort = FlagInfo{
Name: "http-port",
Description: `The port to bind to for HTTP requests.`,
}
ServerHTTPAddr = FlagInfo{
Name: "http-addr",
Description: `The hostname or IP address to bind to for HTTP requests.`,
}
Socket = FlagInfo{
Name: "socket",
EnvVar: "COCKROACH_SOCKET",
Description: `
Unix socket file, postgresql protocol only.
Note: when given a path to a unix socket, most postgres clients will
open "<given path>/.s.PGSQL.<server port>"`,
}
Insecure = FlagInfo{
Name: "insecure",
EnvVar: "COCKROACH_INSECURE",
Description: `
Run over non-encrypted (non-TLS) connections. This is strongly discouraged for
production usage and this flag must be explicitly specified in order for the
server to listen on an external address in insecure mode.`,
}
KeySize = FlagInfo{
Name: "key-size",
Description: `Key size in bits for CA/Node/Client certificates.`,
}
MaxResults = FlagInfo{
Name: "max-results",
Description: `Define the maximum number of results that will be retrieved.`,
}
Password = FlagInfo{
Name: "password",
EnvVar: "COCKROACH_PASSWORD",
Description: `
The created user's password. If provided, disables prompting. Pass '-' to
provide the password on standard input.`,
}
CACert = FlagInfo{
Name: "ca-cert",
EnvVar: "COCKROACH_CA_CERT",
Description: `Path to the CA certificate. Needed by clients and servers in secure mode.`,
}
CAKey = FlagInfo{
Name: "ca-key",
EnvVar: "COCKROACH_CA_KEY",
Description: `Path to the key protecting --ca-cert. Only needed when signing new certificates.`,
}
Cert = FlagInfo{
Name: "cert",
EnvVar: "COCKROACH_CERT",
Description: `Path to the client or server certificate. Needed in secure mode.`,
}
Key = FlagInfo{
Name: "key",
Description: `Path to the key protecting --cert. Needed in secure mode.`,
}
Store = FlagInfo{
Name: "store",
Shorthand: "s",
Description: `
The file path to a storage device. This flag must be specified separately for
each storage device, for example:
<PRE>
--store=/mnt/ssd01 --store=/mnt/ssd02 --store=/mnt/hda1
</PRE>
For each store, the "attrs" and "size" fields can be used to specify device
attributes and a maximum store size (see below). When one or both of these
fields are set, the "path" field label must be used for the path to the storage
device, for example:
<PRE>
--store=path=/mnt/ssd01,attrs=ssd,size=20GiB
</PRE>
In most cases, node-level attributes are preferable to store-level attributes.
However, the "attrs" field can be used to match capabilities for storage of
individual databases or tables. For example, an OLTP database would probably
want to allocate space for its tables only on solid state devices, whereas
append-only time series might prefer cheaper spinning drives. Typical
attributes include whether the store is flash (ssd), spinny disk (hdd), or
in-memory (mem), as well as speeds and other specs. Attributes can be arbitrary
strings separated by colons, for example:
<PRE>
--store=path=/mnt/hda1,attrs=hdd:7200rpm
</PRE>
The store size in the "size" field is not a guaranteed maximum but is used when
calculating free space for rebalancing purposes. The size can be specified
either in a bytes-based unit or as a percentage of hard drive space,
for example:
<PRE>
--store=path=/mnt/ssd01,size=10000000000 -> 10000000000 bytes
--store-path=/mnt/ssd01,size=20GB -> 20000000000 bytes
--store-path=/mnt/ssd01,size=20GiB -> 21474836480 bytes
--store-path=/mnt/ssd01,size=0.02TiB -> 21474836480 bytes
--store=path=/mnt/ssd01,size=20% -> 20% of available space
--store=path=/mnt/ssd01,size=0.2 -> 20% of available space
--store=path=/mnt/ssd01,size=.2 -> 20% of available space
</PRE>
For an in-memory store, the "type" and "size" fields are required, and the
"path" field is forbidden. The "type" field must be set to "mem", and the
"size" field must be set to the true maximum bytes or percentage of available
memory that the store may consume, for example:
<PRE>
--store=type=mem,size=20GiB
--store=type=mem,size=90%
</PRE>
Commas are forbidden in all values, since they are used to separate fields.
Also, if you use equal signs in the file path to a store, you must use the
"path" field label.`,
}
URL = FlagInfo{
Name: "url",
EnvVar: "COCKROACH_URL",
Description: `
Connection url. eg: postgresql://myuser@localhost:26257/mydb
If left empty, the connection flags are used (host, port, user,
database, insecure, certs).`,
}
User = FlagInfo{
Name: "user",
Shorthand: "u",
EnvVar: "COCKROACH_USER",
Description: `Database user name.`,
}
From = FlagInfo{
Name: "from",
Description: `
Start key and format as [<format>:]<key>. Supported formats: raw, human, rangeID.`,
}
To = FlagInfo{
Name: "to",
Description: `
Exclusive end key and format as [<format>:]<key>. Supported formats: raw, human, rangeID.`,
}
Values = FlagInfo{
Name: "values",
Description: `Print values along with their associated key.`,
}
Sizes = FlagInfo{
Name: "sizes",
Description: `Print key and value sizes along with their associated key.`,
}
RaftTickInterval = FlagInfo{
Name: "raft-tick-interval",
Description: `
The resolution of the Raft timer; other raft timeouts are
defined in terms of multiples of this value.`,
}
UndoFreezeCluster = FlagInfo{
Name: "undo",
Description: `Attempt to undo an earlier attempt to freeze the cluster.`,
}
)