cli

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2017 License: Apache-2.0 Imports: 84 Imported by: 0

Documentation

Overview

Example (Cert)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.RunWithCAArgs([]string{"cert", "create-client", "foo"})
c.RunWithCAArgs([]string{"cert", "create-client", "Ομηρος"})
c.RunWithCAArgs([]string{"cert", "create-client", "0foo"})
Output:

cert create-client foo
cert create-client Ομηρος
cert create-client 0foo
failed to generate client certificate and key: username "0foo" invalid; usernames are case insensitive, must start with a letter or underscore, may contain letters, digits or underscores, and must not exceed 63 characters
Example (In_memory)
spec, err := base.NewStoreSpec("type=mem,size=1GiB")
if err != nil {
	panic(err)
}
c := newCLITest(cliTestParams{
	storeSpecs: []base.StoreSpec{spec},
})
defer c.cleanup()

// Test some sql to ensure that the in memory store is working.
c.RunWithArgs([]string{"sql", "-e", "create database t; create table t.f (x int, y int); insert into t.f values (42, 69)"})
c.RunWithArgs([]string{"node", "ls"})
Output:

sql -e create database t; create table t.f (x int, y int); insert into t.f values (42, 69)
INSERT 1
node ls
1 row
id
1
Example (Logging)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.RunWithArgs([]string{"sql", "--logtostderr=false", "-e", "select 1"})
c.RunWithArgs([]string{"sql", "--log-backtrace-at=foo.go:1", "-e", "select 1"})
c.RunWithArgs([]string{"sql", "--log-dir=", "-e", "select 1"})
c.RunWithArgs([]string{"sql", "--logtostderr=true", "-e", "select 1"})
c.RunWithArgs([]string{"sql", "--verbosity=0", "-e", "select 1"})
c.RunWithArgs([]string{"sql", "--vmodule=foo=1", "-e", "select 1"})
Output:

sql --logtostderr=false -e select 1
1 row
1
1
sql --log-backtrace-at=foo.go:1 -e select 1
1 row
1
1
sql --log-dir= -e select 1
1 row
1
1
sql --logtostderr=true -e select 1
1 row
1
1
sql --verbosity=0 -e select 1
1 row
1
1
sql --vmodule=foo=1 -e select 1
1 row
1
1
Example (Max_results)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.Run("debug range split max_results3")
c.Run("debug range split max_results4")
c.Run("debug range ls --max-results=5")
Output:

debug range split max_results3
debug range split max_results4
debug range ls --max-results=5
/Min-/System/"" [1]
	0: node-id=1 store-id=1
/System/""-/System/tsd [2]
	0: node-id=1 store-id=1
/System/tsd-/System/"tse" [3]
	0: node-id=1 store-id=1
/System/"tse"-"max_results3" [4]
	0: node-id=1 store-id=1
"max_results3"-"max_results4" [11]
	0: node-id=1 store-id=1
5 result(s)
Example (Node)
c := newCLITest(cliTestParams{})
defer c.cleanup()

// Refresh time series data, which is required to retrieve stats.
if err := c.WriteSummaries(); err != nil {
	log.Fatalf(context.Background(), "Couldn't write stats summaries: %s", err)
}

c.Run("node ls")
c.Run("node ls --format=pretty")
c.Run("node status 10000")
Output:

node ls
1 row
id
1
node ls --format=pretty
+----+
| id |
+----+
|  1 |
+----+
(1 row)
node status 10000
Error: node 10000 doesn't exist
Example (Ranges)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.Run("debug range split ranges3")
c.Run("debug range ls")
Output:

debug range split ranges3
debug range ls
/Min-/System/"" [1]
	0: node-id=1 store-id=1
/System/""-/System/tsd [2]
	0: node-id=1 store-id=1
/System/tsd-/System/"tse" [3]
	0: node-id=1 store-id=1
/System/"tse"-"ranges3" [4]
	0: node-id=1 store-id=1
"ranges3"-/Table/0 [11]
	0: node-id=1 store-id=1
/Table/0-/Table/11 [5]
	0: node-id=1 store-id=1
/Table/11-/Table/12 [6]
	0: node-id=1 store-id=1
/Table/12-/Table/13 [7]
	0: node-id=1 store-id=1
/Table/13-/Table/14 [8]
	0: node-id=1 store-id=1
/Table/14-/Table/15 [9]
	0: node-id=1 store-id=1
/Table/15-/Max [10]
	0: node-id=1 store-id=1
11 result(s)
Example (Sql)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.RunWithArgs([]string{"sql", "-e", "create database t; create table t.f (x int, y int); insert into t.f values (42, 69)"})
c.RunWithArgs([]string{"sql", "-e", "select 3", "-e", "select * from t.f"})
c.RunWithArgs([]string{"sql", "-e", "begin", "-e", "select 3", "-e", "commit"})
c.RunWithArgs([]string{"sql", "-e", "select * from t.f"})
c.RunWithArgs([]string{"sql", "--execute=show databases"})
c.RunWithArgs([]string{"sql", "-e", "select 1; select 2"})
c.RunWithArgs([]string{"sql", "-e", "select 1; select 2 where false"})
// It must be possible to access pre-defined/virtual tables even if the current database
// does not exist yet.
c.RunWithArgs([]string{"sql", "-d", "nonexistent", "-e", "select count(*) from pg_class limit 0"})
// It must be possible to create the current database after the
// connection was established.
c.RunWithArgs([]string{"sql", "-d", "nonexistent", "-e", "create database nonexistent; create table foo(x int); select * from foo"})
Output:

sql -e create database t; create table t.f (x int, y int); insert into t.f values (42, 69)
INSERT 1
sql -e select 3 -e select * from t.f
1 row
3
3
1 row
x	y
42	69
sql -e begin -e select 3 -e commit
BEGIN
1 row
3
3
COMMIT
sql -e select * from t.f
1 row
x	y
42	69
sql --execute=show databases
5 rows
Database
crdb_internal
information_schema
pg_catalog
system
t
sql -e select 1; select 2
1 row
1
1
1 row
2
2
sql -e select 1; select 2 where false
1 row
1
1
0 rows
2
sql -d nonexistent -e select count(*) from pg_class limit 0
0 rows
count(*)
sql -d nonexistent -e create database nonexistent; create table foo(x int); select * from foo
0 rows
x
Example (Sql_column_labels)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.RunWithArgs([]string{"sql", "-e", "create database t; create table t.u (\"\"\"foo\" int, \"\\foo\" int, \"foo\nbar\" int, \"κόσμε\" int, \"a|b\" int, \"܈85\" int)"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.u values (0, 0, 0, 0, 0, 0)"})
c.RunWithArgs([]string{"sql", "-e", "show columns from t.u"})
c.RunWithArgs([]string{"sql", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=pretty", "-e", "show columns from t.u"})
c.RunWithArgs([]string{"sql", "--format=pretty", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=tsv", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=csv", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=sql", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=html", "-e", "select * from t.u"})
c.RunWithArgs([]string{"sql", "--format=records", "-e", "select * from t.u"})
Output:

sql -e create database t; create table t.u ("""foo" int, "\foo" int, "foo
bar" int, "κόσμε" int, "a|b" int, "܈85" int)
CREATE TABLE
sql -e insert into t.u values (0, 0, 0, 0, 0, 0)
INSERT 1
sql -e show columns from t.u
6 rows
Field	Type	Null	Default	Indices
"""foo"	INT	true	NULL	{}
\foo	INT	true	NULL	{}
"foo
bar"	INT	true	NULL	{}
κόσμε	INT	true	NULL	{}
a|b	INT	true	NULL	{}
܈85	INT	true	NULL	{}
sql -e select * from t.u
1 row
"""foo"	\foo	"""foo\nbar"""	κόσμε	a|b	܈85
0	0	0	0	0	0
sql --format=pretty -e show columns from t.u
+---------+------+------+---------+---------+
|  Field  | Type | Null | Default | Indices |
+---------+------+------+---------+---------+
| "foo    | INT  | true | NULL    | {}      |
| \foo    | INT  | true | NULL    | {}      |
| foo␤    | INT  | true | NULL    | {}      |
| bar     |      |      |         |         |
| κόσμε   | INT  | true | NULL    | {}      |
| a|b     | INT  | true | NULL    | {}      |
| ܈85     | INT  | true | NULL    | {}      |
+---------+------+------+---------+---------+
(6 rows)
sql --format=pretty -e select * from t.u
+------+------+------------+-------+-----+-----+
| "foo | \foo | "foo\nbar" | κόσμε | a|b | ܈85 |
+------+------+------------+-------+-----+-----+
|    0 |    0 |          0 |     0 |   0 |   0 |
+------+------+------------+-------+-----+-----+
(1 row)
sql --format=tsv -e select * from t.u
1 row
"""foo"	\foo	"""foo\nbar"""	κόσμε	a|b	܈85
0	0	0	0	0	0
sql --format=csv -e select * from t.u
1 row
"""foo",\foo,"""foo\nbar""",κόσμε,a|b,܈85
0,0,0,0,0,0
sql --format=sql -e select * from t.u
CREATE TABLE results (
  """foo" STRING,
  "\foo" STRING,
  """foo\nbar""" STRING,
  "κόσμε" STRING,
  "a|b" STRING,
  ܈85 STRING
);

INSERT INTO results VALUES ('0', '0', '0', '0', '0', '0');
sql --format=html -e select * from t.u
<table>
<thead><tr><th>&#34;foo</th><th>\foo</th><th>&#34;foo\nbar&#34;</th><th>κόσμε</th><th>a|b</th><th>܈85</th></tr></head>
<tbody>
<tr><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr>
</tbody>
</table>
sql --format=records -e select * from t.u
-[ RECORD 1 ]
"foo       | 0
\foo       | 0
"foo\nbar" | 0
κόσμε      | 0
a|b        | 0
܈85        | 0
Example (Sql_format)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.RunWithArgs([]string{"sql", "-e", "create database t; create table t.times (bare timestamp, withtz timestamptz)"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.times values ('2016-01-25 10:10:10', '2016-01-25 10:10:10-05:00')"})
c.RunWithArgs([]string{"sql", "-e", "select * from t.times"})
Output:

sql -e create database t; create table t.times (bare timestamp, withtz timestamptz)
CREATE TABLE
sql -e insert into t.times values ('2016-01-25 10:10:10', '2016-01-25 10:10:10-05:00')
INSERT 1
sql -e select * from t.times
1 row
bare	withtz
2016-01-25 10:10:10+00:00	2016-01-25 15:10:10+00:00
Example (Sql_table)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.RunWithArgs([]string{"sql", "-e", "create database t; create table t.t (s string, d string);"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'foo', 'printable ASCII')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\"foo', 'printable ASCII with quotes')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\\\\foo', 'printable ASCII with backslash')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'foo\\x0abar', 'non-printable ASCII')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values ('κόσμε', 'printable UTF8')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\\xc3\\xb1', 'printable UTF8 using escapes')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\\x01', 'non-printable UTF8 string')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\\xdc\\x88\\x38\\x35', 'UTF8 string with RTL char')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'\\xc3\\x28', 'non-UTF8 string')"})
c.RunWithArgs([]string{"sql", "-e", "insert into t.t values (e'a\\tb\\tc\\n12\\t123123213\\t12313', 'tabs')"})
c.RunWithArgs([]string{"sql", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=pretty", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=tsv", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=csv", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=sql", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=html", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=records", "-e", "select * from t.t"})
c.RunWithArgs([]string{"sql", "--format=pretty", "-e", "select '  hai' as x"})
c.RunWithArgs([]string{"sql", "--format=pretty", "-e", "explain(indent) select s from t.t union all select s from t.t"})
Output:

sql -e create database t; create table t.t (s string, d string);
CREATE TABLE
sql -e insert into t.t values (e'foo', 'printable ASCII')
INSERT 1
sql -e insert into t.t values (e'"foo', 'printable ASCII with quotes')
INSERT 1
sql -e insert into t.t values (e'\\foo', 'printable ASCII with backslash')
INSERT 1
sql -e insert into t.t values (e'foo\x0abar', 'non-printable ASCII')
INSERT 1
sql -e insert into t.t values ('κόσμε', 'printable UTF8')
INSERT 1
sql -e insert into t.t values (e'\xc3\xb1', 'printable UTF8 using escapes')
INSERT 1
sql -e insert into t.t values (e'\x01', 'non-printable UTF8 string')
INSERT 1
sql -e insert into t.t values (e'\xdc\x88\x38\x35', 'UTF8 string with RTL char')
INSERT 1
sql -e insert into t.t values (e'\xc3\x28', 'non-UTF8 string')
pq: invalid UTF-8 byte sequence
insert into t.t values (e'\xc3\x28', 'non-UTF8 string')
                        ^

sql -e insert into t.t values (e'a\tb\tc\n12\t123123213\t12313', 'tabs')
INSERT 1
sql -e select * from t.t
9 rows
s	d
foo	printable ASCII
"""foo"	printable ASCII with quotes
\foo	printable ASCII with backslash
"foo
bar"	non-printable ASCII
κόσμε	printable UTF8
ñ	printable UTF8 using escapes
"""\x01"""	non-printable UTF8 string
܈85	UTF8 string with RTL char
"a	b	c
12	123123213	12313"	tabs
sql --format=pretty -e select * from t.t
+--------------------------------+--------------------------------+
|               s                |               d                |
+--------------------------------+--------------------------------+
| foo                            | printable ASCII                |
| "foo                           | printable ASCII with quotes    |
| \foo                           | printable ASCII with backslash |
| foo␤                           | non-printable ASCII            |
| bar                            |                                |
| κόσμε                          | printable UTF8                 |
| ñ                              | printable UTF8 using escapes   |
| "\x01"                         | non-printable UTF8 string      |
| ܈85                            | UTF8 string with RTL char      |
| a   b         c␤               | tabs                           |
| 12  123123213 12313            |                                |
+--------------------------------+--------------------------------+
(9 rows)
sql --format=tsv -e select * from t.t
9 rows
s	d
foo	printable ASCII
"""foo"	printable ASCII with quotes
\foo	printable ASCII with backslash
"foo
bar"	non-printable ASCII
κόσμε	printable UTF8
ñ	printable UTF8 using escapes
"""\x01"""	non-printable UTF8 string
܈85	UTF8 string with RTL char
"a	b	c
12	123123213	12313"	tabs
sql --format=csv -e select * from t.t
9 rows
s,d
foo,printable ASCII
"""foo",printable ASCII with quotes
\foo,printable ASCII with backslash
"foo
bar",non-printable ASCII
κόσμε,printable UTF8
ñ,printable UTF8 using escapes
"""\x01""",non-printable UTF8 string
܈85,UTF8 string with RTL char
"a	b	c
12	123123213	12313",tabs
sql --format=sql -e select * from t.t
CREATE TABLE results (
  s STRING,
  d STRING
);

INSERT INTO results VALUES ('foo', 'printable ASCII');
INSERT INTO results VALUES ('"foo', 'printable ASCII with quotes');
INSERT INTO results VALUES (e'\\foo', 'printable ASCII with backslash');
INSERT INTO results VALUES (e'foo\nbar', 'non-printable ASCII');
INSERT INTO results VALUES (e'\u03BA\U00001F79\u03C3\u03BC\u03B5', 'printable UTF8');
INSERT INTO results VALUES (e'\u00F1', 'printable UTF8 using escapes');
INSERT INTO results VALUES (e'"\\x01"', 'non-printable UTF8 string');
INSERT INTO results VALUES (e'\u070885', 'UTF8 string with RTL char');
INSERT INTO results VALUES (e'a\tb\tc\n12\t123123213\t12313', 'tabs');
sql --format=html -e select * from t.t
<table>
<thead><tr><th>s</th><th>d</th></tr></head>
<tbody>
<tr><td>foo</td><td>printable ASCII</td></tr>
<tr><td>&#34;foo</td><td>printable ASCII with quotes</td></tr>
<tr><td>\foo</td><td>printable ASCII with backslash</td></tr>
<tr><td>foo<br/>bar</td><td>non-printable ASCII</td></tr>
<tr><td>κόσμε</td><td>printable UTF8</td></tr>
<tr><td>ñ</td><td>printable UTF8 using escapes</td></tr>
<tr><td>&#34;\x01&#34;</td><td>non-printable UTF8 string</td></tr>
<tr><td>܈85</td><td>UTF8 string with RTL char</td></tr>
<tr><td>a	b	c<br/>12	123123213	12313</td><td>tabs</td></tr>
</tbody>
</table>
sql --format=records -e select * from t.t
-[ RECORD 1 ]
s | foo
d | printable ASCII
-[ RECORD 2 ]
s | "foo
d | printable ASCII with quotes
-[ RECORD 3 ]
s | \foo
d | printable ASCII with backslash
-[ RECORD 4 ]
s | foo
  | bar
d | non-printable ASCII
-[ RECORD 5 ]
s | κόσμε
d | printable UTF8
-[ RECORD 6 ]
s | ñ
d | printable UTF8 using escapes
-[ RECORD 7 ]
s | "\x01"
d | non-printable UTF8 string
-[ RECORD 8 ]
s | ܈85
d | UTF8 string with RTL char
-[ RECORD 9 ]
s | a	b	c
  | 12	123123213	12313
d | tabs
sql --format=pretty -e select '  hai' as x
+-------+
|   x   |
+-------+
|   hai |
+-------+
(1 row)
sql --format=pretty -e explain(indent) select s from t.t union all select s from t.t
+-------+--------+-------+--------------------+
| Level |  Type  | Field |    Description     |
+-------+--------+-------+--------------------+
|     0 | append |       |  -> append         |
|     1 | render |       |    -> render       |
|     2 | scan   |       |       -> scan      |
|     2 |        | table |          t@primary |
|     2 |        | spans |          ALL       |
|     1 | render |       |    -> render       |
|     2 | scan   |       |       -> scan      |
|     2 |        | table |          t@primary |
|     2 |        | spans |          ALL       |
+-------+--------+-------+--------------------+
(9 rows)
Example (User)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.Run("user ls")
c.Run("user ls --format=pretty")
c.Run("user ls --format=tsv")
c.Run("user set FOO")
c.Run("user set Foo")
c.Run("user set fOo")
c.Run("user set foO")
c.Run("user set foo")
c.Run("user set _foo")
c.Run("user set f_oo")
c.Run("user set foo_")
c.Run("user set ,foo")
c.Run("user set f,oo")
c.Run("user set foo,")
c.Run("user set 0foo")
c.Run("user set foo0")
c.Run("user set f0oo")
c.Run("user set foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoof")
c.Run("user set foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo")
c.Run("user set Ομηρος")
// Try some reserved keywords.
c.Run("user set and")
c.Run("user set table")
// Don't use get, since the output of hashedPassword is random.
// c.Run("user get foo")
c.Run("user ls --format=pretty")
c.Run("user rm foo")
c.Run("user ls --format=pretty")
Output:

user ls
0 rows
username
user ls --format=pretty
+----------+
| username |
+----------+
+----------+
(0 rows)
user ls --format=tsv
0 rows
username
user set FOO
INSERT 1
user set Foo
INSERT 1
user set fOo
INSERT 1
user set foO
INSERT 1
user set foo
INSERT 1
user set _foo
INSERT 1
user set f_oo
INSERT 1
user set foo_
INSERT 1
user set ,foo
username ",foo" invalid; usernames are case insensitive, must start with a letter or underscore, may contain letters, digits or underscores, and must not exceed 63 characters
user set f,oo
username "f,oo" invalid; usernames are case insensitive, must start with a letter or underscore, may contain letters, digits or underscores, and must not exceed 63 characters
user set foo,
username "foo," invalid; usernames are case insensitive, must start with a letter or underscore, may contain letters, digits or underscores, and must not exceed 63 characters
user set 0foo
username "0foo" invalid; usernames are case insensitive, must start with a letter or underscore, may contain letters, digits or underscores, and must not exceed 63 characters
user set foo0
INSERT 1
user set f0oo
INSERT 1
user set foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoof
username "foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoof" invalid; usernames are case insensitive, must start with a letter or underscore, may contain letters, digits or underscores, and must not exceed 63 characters
user set foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo
INSERT 1
user set Ομηρος
INSERT 1
user set and
INSERT 1
user set table
INSERT 1
user ls --format=pretty
+-----------------------------------------------------------------+
|                            username                             |
+-----------------------------------------------------------------+
| _foo                                                            |
| and                                                             |
| f0oo                                                            |
| f_oo                                                            |
| foo                                                             |
| foo0                                                            |
| foo_                                                            |
| foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo |
| table                                                           |
| ομηρος                                                          |
+-----------------------------------------------------------------+
(10 rows)
user rm foo
DELETE 1
user ls --format=pretty
+-----------------------------------------------------------------+
|                            username                             |
+-----------------------------------------------------------------+
| _foo                                                            |
| and                                                             |
| f0oo                                                            |
| f_oo                                                            |
| foo0                                                            |
| foo_                                                            |
| foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo |
| table                                                           |
| ομηρος                                                          |
+-----------------------------------------------------------------+
(9 rows)
Example (Zone)
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.Run("zone ls")
c.Run("zone set system --file=./testdata/zone_attrs.yaml")
c.Run("zone ls")
c.Run("zone get .meta")
c.Run("zone get system.nonexistent")
c.Run("zone get system.lease")
c.Run("zone set system.lease --file=./testdata/zone_attrs.yaml")
c.Run("zone set system.namespace --file=./testdata/zone_attrs.yaml")
c.Run("zone set system.nonexistent --file=./testdata/zone_attrs.yaml")
c.Run("zone set system --file=./testdata/zone_range_max_bytes.yaml")
c.Run("zone get system")
c.Run("zone rm system")
c.Run("zone ls")
c.Run("zone rm .default")
c.Run("zone set .meta --file=./testdata/zone_range_max_bytes.yaml")
c.Run("zone set .system --file=./testdata/zone_range_max_bytes.yaml")
c.Run("zone set .timeseries --file=./testdata/zone_range_max_bytes.yaml")
c.Run("zone get .system")
c.Run("zone ls")
c.Run("zone set .default --file=./testdata/zone_range_max_bytes.yaml")
c.Run("zone get system")
c.Run("zone set .default --disable-replication")
c.Run("zone get system")
c.Run("zone rm .meta")
c.Run("zone rm .system")
c.Run("zone ls")
c.Run("zone rm .timeseries")
c.Run("zone ls")
c.Run("zone rm .meta")
c.Run("zone rm .system")
c.Run("zone rm .timeseries")
Output:

zone ls
.default
zone set system --file=./testdata/zone_attrs.yaml
range_min_bytes: 1048576
range_max_bytes: 67108864
gc:
  ttlseconds: 86400
num_replicas: 1
constraints: [us-east-1a, ssd]
zone ls
.default
system
zone get .meta
.default
range_min_bytes: 1048576
range_max_bytes: 67108864
gc:
  ttlseconds: 86400
num_replicas: 1
constraints: []
zone get system.nonexistent
system.nonexistent not found
zone get system.lease
system
range_min_bytes: 1048576
range_max_bytes: 67108864
gc:
  ttlseconds: 86400
num_replicas: 1
constraints: [us-east-1a, ssd]
zone set system.lease --file=./testdata/zone_attrs.yaml
setting zone configs for individual system tables is not supported; try setting your config on the entire "system" database instead
zone set system.namespace --file=./testdata/zone_attrs.yaml
setting zone configs for individual system tables is not supported; try setting your config on the entire "system" database instead
zone set system.nonexistent --file=./testdata/zone_attrs.yaml
system.nonexistent not found
zone set system --file=./testdata/zone_range_max_bytes.yaml
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: [us-east-1a, ssd]
zone get system
system
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: [us-east-1a, ssd]
zone rm system
DELETE 1
zone ls
.default
zone rm .default
unable to remove special zone .default
zone set .meta --file=./testdata/zone_range_max_bytes.yaml
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: []
zone set .system --file=./testdata/zone_range_max_bytes.yaml
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: []
zone set .timeseries --file=./testdata/zone_range_max_bytes.yaml
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: []
zone get .system
.system
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: []
zone ls
.default
.meta
.system
.timeseries
zone set .default --file=./testdata/zone_range_max_bytes.yaml
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: []
zone get system
.default
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 3
constraints: []
zone set .default --disable-replication
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 1
constraints: []
zone get system
.default
range_min_bytes: 1048576
range_max_bytes: 134217728
gc:
  ttlseconds: 86400
num_replicas: 1
constraints: []
zone rm .meta
DELETE 1
zone rm .system
DELETE 1
zone ls
.default
.timeseries
zone rm .timeseries
DELETE 1
zone ls
.default
zone rm .meta
DELETE 0
zone rm .system
DELETE 0
zone rm .timeseries
DELETE 0

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrorCode = 1

ErrorCode is the value to be used by main() as exit code in case of error. For most errors 1 is appropriate, but a signal termination can change this.

Functions

func InitCLIDefaults

func InitCLIDefaults()

InitCLIDefaults is used for testing.

func Main

func Main()

Main is the entry point for the cli, with a single line calling it intended to be the body of an action package main `main` func elsewhere. It is abstracted for reuse by duplicated `main` funcs in different distributions.

func MakeDBClient

func MakeDBClient() (*client.DB, *stop.Stopper, error)

MakeDBClient creates a kv client for use in cli tools.

func MaybeDecorateGRPCError

func MaybeDecorateGRPCError(
	wrapped func(*cobra.Command, []string) error,
) func(*cobra.Command, []string) error

MaybeDecorateGRPCError catches grpc errors and provides a more helpful error message to the user.

func MaybeShoutError

func MaybeShoutError(
	wrapped func(*cobra.Command, []string) error,
) func(*cobra.Command, []string) error

MaybeShoutError calls log.Shout on errors, better surfacing problems to the user.

func Run

func Run(args []string) error

Run ...

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL