@toa.io/cli 1.1.0-dev.10 → 1.1.0-dev.12
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 +22 -10
- package/src/commands/shell.js +22 -0
- package/src/handlers/shell.js +29 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/cli",
|
|
3
|
-
"version": "1.1.0-dev.
|
|
3
|
+
"version": "1.1.0-dev.12",
|
|
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.11.0-dev.
|
|
27
|
-
"@toa.io/kubernetes": "0.7.5-dev.
|
|
28
|
-
"@toa.io/norm": "1.0.2-dev.
|
|
29
|
-
"@toa.io/yaml": "0.7.6-dev.
|
|
26
|
+
"@toa.io/generic": "0.11.0-dev.12",
|
|
27
|
+
"@toa.io/kubernetes": "0.7.5-dev.12",
|
|
28
|
+
"@toa.io/norm": "1.0.2-dev.12",
|
|
29
|
+
"@toa.io/yaml": "0.7.6-dev.12",
|
|
30
30
|
"find-up": "5.0.0",
|
|
31
31
|
"yargs": "17.6.2"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "e80500549e76c0e35407a4b3af5a5a38a4e33686"
|
|
34
34
|
}
|
package/readme.md
CHANGED
|
@@ -57,9 +57,10 @@ the context will be found and replayed sequentially.
|
|
|
57
57
|
<code>--error</code> print errors only<br/>
|
|
58
58
|
</dd>
|
|
59
59
|
</dl>
|
|
60
|
-
## Deployment
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
## Operations
|
|
62
|
+
|
|
63
|
+
> Commands use current Kubernetes context.
|
|
63
64
|
|
|
64
65
|
### deploy
|
|
65
66
|
|
|
@@ -74,15 +75,8 @@ the context will be found and replayed sequentially.
|
|
|
74
75
|
### conceal
|
|
75
76
|
|
|
76
77
|
<dl>
|
|
77
|
-
<dt>
|
|
78
|
-
<code>toa conceal</code>
|
|
79
|
-
</dt>
|
|
80
|
-
<dd>Deploy new declared secrets.
|
|
81
|
-
|
|
82
|
-
<code>--reset</code> don't skip already deployed</dd>
|
|
83
|
-
|
|
84
78
|
<dt><code>toa conceal <secret> <key> <value></code></dt>
|
|
85
|
-
<dd>Deploy a <code>key</code> with a <code>value</code> to a <code>secret</code>.</dd>
|
|
79
|
+
<dd>Deploy a <code>key</code> with a <code>value</code> to a secret named <code>toa-{secret}</code>.</dd>
|
|
86
80
|
</dl>
|
|
87
81
|
|
|
88
82
|
### reveal
|
|
@@ -93,3 +87,21 @@ the context will be found and replayed sequentially.
|
|
|
93
87
|
</dt>
|
|
94
88
|
<dd>Print keys and values of a secret.</dd>
|
|
95
89
|
</dl>
|
|
90
|
+
|
|
91
|
+
### shell
|
|
92
|
+
|
|
93
|
+
<dl>
|
|
94
|
+
<dt>
|
|
95
|
+
<code>toa shell [image]</code>
|
|
96
|
+
</dt>
|
|
97
|
+
<dd>Run interactive shell inside a disposable pod.
|
|
98
|
+
|
|
99
|
+
<code>image</code> docker image<br/>
|
|
100
|
+
</dd>
|
|
101
|
+
</dl>
|
|
102
|
+
|
|
103
|
+
Extra arguments can be passed:
|
|
104
|
+
|
|
105
|
+
```shell
|
|
106
|
+
$ toa shell -- ping 1.1
|
|
107
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { shell } = require('../handlers/shell')
|
|
4
|
+
|
|
5
|
+
const builder = (yargs) => {
|
|
6
|
+
yargs
|
|
7
|
+
.positional('image', {
|
|
8
|
+
group: 'Command options:',
|
|
9
|
+
type: 'string',
|
|
10
|
+
desc: 'Docker image',
|
|
11
|
+
default: 'alpine'
|
|
12
|
+
})
|
|
13
|
+
.example([
|
|
14
|
+
['$0 shell'],
|
|
15
|
+
['$0 shell -- ping localhost']
|
|
16
|
+
])
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.command = 'shell [image]'
|
|
20
|
+
exports.desc = 'Run interactive shell from the current Kubernetes context'
|
|
21
|
+
exports.builder = builder
|
|
22
|
+
exports.handler = shell
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('node:child_process')
|
|
4
|
+
const { newid } = require('@toa.io/generic')
|
|
5
|
+
|
|
6
|
+
const shell = async (argv) => {
|
|
7
|
+
const rnd = newid().substring(0, 6)
|
|
8
|
+
|
|
9
|
+
const args = [
|
|
10
|
+
'run',
|
|
11
|
+
'shell-' + rnd,
|
|
12
|
+
'--rm',
|
|
13
|
+
'-i',
|
|
14
|
+
'--tty',
|
|
15
|
+
'--image',
|
|
16
|
+
argv.image,
|
|
17
|
+
'--restart=Never',
|
|
18
|
+
'--'
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
const extra = argv._.splice(1)
|
|
22
|
+
|
|
23
|
+
if (extra.length > 0) args.push(...extra)
|
|
24
|
+
else args.push('sh')
|
|
25
|
+
|
|
26
|
+
await spawn('kubectl', args, { stdio: 'inherit' })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.shell = shell
|