@toa.io/cli 1.0.1 → 1.1.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/readme.md +10 -51
- package/src/handlers/conceal.js +5 -1
- package/src/handlers/reveal.js +4 -1
- package/src/commands/configure.js +0 -43
- package/src/handlers/.configure/subcommands.js +0 -15
- package/src/handlers/configure.js +0 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-dev.0",
|
|
4
4
|
"description": "Toa CLI",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@toa.io/console": "0.6.0",
|
|
26
|
-
"@toa.io/generic": "0.
|
|
27
|
-
"@toa.io/kubernetes": "0.7.
|
|
28
|
-
"@toa.io/norm": "1.0.
|
|
29
|
-
"@toa.io/yaml": "0.7.
|
|
26
|
+
"@toa.io/generic": "0.11.0-dev.0",
|
|
27
|
+
"@toa.io/kubernetes": "0.7.5-dev.0",
|
|
28
|
+
"@toa.io/norm": "1.0.2-dev.0",
|
|
29
|
+
"@toa.io/yaml": "0.7.6-dev.0",
|
|
30
30
|
"find-up": "5.0.0",
|
|
31
31
|
"yargs": "17.6.2"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "44a59b3ec335a1be8655b543891767bae799dba1"
|
|
34
34
|
}
|
package/readme.md
CHANGED
|
@@ -2,43 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
## Development
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
Outputs shell commands to manipulate local environment variables, thus must be piped
|
|
8
|
-
with `source /dev/stdin` to apply.
|
|
5
|
+
### env
|
|
9
6
|
|
|
10
7
|
<dl>
|
|
11
|
-
<dt><code>toa
|
|
12
|
-
<dd>
|
|
13
|
-
Set Configuration Object key. Nested keys are addressed with dot notation.
|
|
14
|
-
|
|
15
|
-
<code>--path</code> path to component (default <code>.</code>)<br/>
|
|
16
|
-
<code>--reset</code> clear <code>key</code><br/>
|
|
17
|
-
|
|
18
|
-
#### Examples
|
|
19
|
-
|
|
20
|
-
> It is assumed you are in the component's directory, use `--path` otherwise.
|
|
21
|
-
|
|
22
|
-
```shell
|
|
23
|
-
# set new value
|
|
24
|
-
$ toa configure foo 'new value' | source /dev/stdin
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
```shell
|
|
28
|
-
# clear key
|
|
29
|
-
$ toa configure bar.baz --reset | source /dev/stdin
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
</dd>
|
|
33
|
-
<dt><code>toa configure reset</code></dt>
|
|
34
|
-
<dd>Remove Configuration Object.</dd>
|
|
35
|
-
<dt><code>toa configure print</code></dt>
|
|
36
|
-
<dd>Output Configuration Object as YAML.
|
|
8
|
+
<dt><code>toa env [environment]</code></dt>
|
|
9
|
+
<dd>Set local environment variables to a <code>.env</code> file.
|
|
37
10
|
|
|
38
|
-
<code
|
|
11
|
+
<code>environment</code> deployment environment name (default <code>local</code>).<br/>
|
|
12
|
+
<code>--path</code> path to context (default <code>.</code>)<br/>
|
|
39
13
|
</dd>
|
|
40
14
|
</dl>
|
|
41
15
|
|
|
16
|
+
Credentials specified in `.env` file are preserved.
|
|
17
|
+
|
|
18
|
+
> It is recommended to add `.env` to `.gitignore`.
|
|
19
|
+
|
|
42
20
|
### replay
|
|
43
21
|
|
|
44
22
|
[Replay](/extensions/sampling/docs/replay.md) samples. Reports in [TAP](https://testanything.org)
|
|
@@ -66,11 +44,9 @@ $ toa replay ./path/to/context
|
|
|
66
44
|
$ toa replay --title "should add numbers"
|
|
67
45
|
```
|
|
68
46
|
|
|
69
|
-
If path is a context directory (containing `context.toa.yaml` file), samples for components within
|
|
47
|
+
If a path is a context directory (containing `context.toa.yaml` file), samples for components within
|
|
70
48
|
the context will be found and replayed sequentially.
|
|
71
49
|
|
|
72
|
-
## Exporting
|
|
73
|
-
|
|
74
50
|
### export manifest
|
|
75
51
|
|
|
76
52
|
<dl>
|
|
@@ -81,22 +57,6 @@ the context will be found and replayed sequentially.
|
|
|
81
57
|
<code>--error</code> print errors only<br/>
|
|
82
58
|
</dd>
|
|
83
59
|
</dl>
|
|
84
|
-
|
|
85
|
-
### env
|
|
86
|
-
|
|
87
|
-
<dl>
|
|
88
|
-
<dt><code>toa env [environment]</code></dt>
|
|
89
|
-
<dd>Select environment. Set local environment variables to <code>.env</code> file.
|
|
90
|
-
|
|
91
|
-
<code>environment</code> deployment environment name (default <code>local</code>).<br/>
|
|
92
|
-
<code>--path</code> path to context (default <code>.</code>)<br/>
|
|
93
|
-
</dd>
|
|
94
|
-
</dl>
|
|
95
|
-
|
|
96
|
-
> It is recommended to add `.env` to `.gitignore`.
|
|
97
|
-
|
|
98
|
-
> Credentials specified in a `.env` file are preserved during environment selection.
|
|
99
|
-
|
|
100
60
|
## Deployment
|
|
101
61
|
|
|
102
62
|
> Deployment commands use current `kubectl` context.
|
|
@@ -116,7 +76,6 @@ the context will be found and replayed sequentially.
|
|
|
116
76
|
<dl>
|
|
117
77
|
<dt>
|
|
118
78
|
<code>toa conceal</code>
|
|
119
|
-
<img src="https://img.shields.io/badge/Not_Implemented-red" alt="Not Implemented"/>
|
|
120
79
|
</dt>
|
|
121
80
|
<dd>Deploy new declared secrets.
|
|
122
81
|
|
package/src/handlers/conceal.js
CHANGED
|
@@ -4,8 +4,12 @@ const { secrets } = require('@toa.io/kubernetes')
|
|
|
4
4
|
|
|
5
5
|
const conceal = async (argv) => {
|
|
6
6
|
const { secret, key, value } = argv
|
|
7
|
+
const prefixed = PREFIX + secret
|
|
7
8
|
|
|
8
|
-
await secrets.store(
|
|
9
|
+
await secrets.store(prefixed, { [key]: value })
|
|
9
10
|
}
|
|
10
11
|
|
|
12
|
+
const PREFIX = 'toa-'
|
|
13
|
+
|
|
11
14
|
exports.conceal = conceal
|
|
15
|
+
exports.PREFIX = PREFIX
|
package/src/handlers/reveal.js
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
const { secrets } = require('@toa.io/kubernetes')
|
|
4
4
|
const { remap, decode } = require('@toa.io/generic')
|
|
5
5
|
|
|
6
|
+
const { PREFIX } = require('./conceal')
|
|
7
|
+
|
|
6
8
|
const reveal = async (argv) => {
|
|
7
|
-
const
|
|
9
|
+
const prefixed = PREFIX + argv.secret
|
|
10
|
+
const secret = await secrets.get(prefixed)
|
|
8
11
|
const values = remap(secret.data, decode)
|
|
9
12
|
|
|
10
13
|
for (const [key, value] of Object.entries(values)) {
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { configure } = require('../handlers/configure')
|
|
4
|
-
|
|
5
|
-
const builder = (yargs) => {
|
|
6
|
-
yargs
|
|
7
|
-
.positional('key', {
|
|
8
|
-
type: 'string',
|
|
9
|
-
desc: 'Configuration Object key'
|
|
10
|
-
})
|
|
11
|
-
.positional('value', {
|
|
12
|
-
type: 'string',
|
|
13
|
-
desc: 'Key value'
|
|
14
|
-
})
|
|
15
|
-
.option('path', {
|
|
16
|
-
alias: 'p',
|
|
17
|
-
group: 'Command options:',
|
|
18
|
-
describe: 'Path to component',
|
|
19
|
-
type: 'string',
|
|
20
|
-
default: '.'
|
|
21
|
-
})
|
|
22
|
-
.option('reset', {
|
|
23
|
-
group: 'Command options:',
|
|
24
|
-
type: 'boolean',
|
|
25
|
-
desc: 'Remove Configuration Object key'
|
|
26
|
-
})
|
|
27
|
-
.option('json', {
|
|
28
|
-
group: 'Command options:',
|
|
29
|
-
type: 'boolean',
|
|
30
|
-
desc: 'Print as JSON'
|
|
31
|
-
})
|
|
32
|
-
.example([
|
|
33
|
-
['$0 configure myKey \'new value\' | source /dev/stdin'],
|
|
34
|
-
['$0 configure myObject.myKey --reset | source /dev/stdin'],
|
|
35
|
-
['$0 configure reset | source /dev/stdin'],
|
|
36
|
-
['$0 configure print --json']
|
|
37
|
-
])
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exports.command = 'configure [key] [value]'
|
|
41
|
-
exports.desc = 'Output shell command to update local environment Configuration Object'
|
|
42
|
-
exports.builder = builder
|
|
43
|
-
exports.handler = configure
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { dump } = require('@toa.io/yaml')
|
|
4
|
-
|
|
5
|
-
const reset = (provider) => console.log('unset ' + provider.key)
|
|
6
|
-
|
|
7
|
-
const print = async (provider, argv) => {
|
|
8
|
-
await provider.connect()
|
|
9
|
-
|
|
10
|
-
const formatter = argv.json ? JSON.stringify : dump
|
|
11
|
-
|
|
12
|
-
console.log(formatter(provider.object))
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
exports.subcommands = { print, reset }
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const boot = require('@toa.io/boot')
|
|
4
|
-
|
|
5
|
-
const { Factory } = require('@toa.io/extensions.configuration')
|
|
6
|
-
|
|
7
|
-
const { subcommands } = require('./.configure/subcommands')
|
|
8
|
-
const { components: find } = require('../util/find')
|
|
9
|
-
|
|
10
|
-
async function configure (argv) {
|
|
11
|
-
const path = find(argv.path)
|
|
12
|
-
const manifest = await boot.manifest(path)
|
|
13
|
-
const factory = new Factory()
|
|
14
|
-
const provider = factory.provider(manifest)
|
|
15
|
-
|
|
16
|
-
if (argv.value === undefined && subcommands[argv.key] !== undefined) {
|
|
17
|
-
await subcommands[argv.key](provider, argv)
|
|
18
|
-
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
await provider.connect()
|
|
23
|
-
|
|
24
|
-
let key = argv.key
|
|
25
|
-
let value = argv.value
|
|
26
|
-
|
|
27
|
-
// :(
|
|
28
|
-
if (key !== undefined) {
|
|
29
|
-
if (value === undefined && key.includes('=')) [key, value] = key.split('=')
|
|
30
|
-
|
|
31
|
-
if (value === undefined) {
|
|
32
|
-
if (argv.reset !== true) throw new Error('Key value expected')
|
|
33
|
-
else provider.unset(key)
|
|
34
|
-
} else provider.set(key, value)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let command
|
|
38
|
-
const exported = provider.export()
|
|
39
|
-
|
|
40
|
-
if (exported === undefined) command = `unset ${provider.key}`
|
|
41
|
-
else command = `export ${provider.key}=` + exported
|
|
42
|
-
|
|
43
|
-
console.log(command)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
exports.configure = configure
|