@toa.io/cli 1.1.0-dev.10 → 1.1.0-dev.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/cli",
3
- "version": "1.1.0-dev.10",
3
+ "version": "1.1.0-dev.11",
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.10",
27
- "@toa.io/kubernetes": "0.7.5-dev.10",
28
- "@toa.io/norm": "1.0.2-dev.10",
29
- "@toa.io/yaml": "0.7.6-dev.10",
26
+ "@toa.io/generic": "0.11.0-dev.11",
27
+ "@toa.io/kubernetes": "0.7.5-dev.11",
28
+ "@toa.io/norm": "1.0.2-dev.11",
29
+ "@toa.io/yaml": "0.7.6-dev.11",
30
30
  "find-up": "5.0.0",
31
31
  "yargs": "17.6.2"
32
32
  },
33
- "gitHead": "df6df35ff3e9f2d9416118a979d3885a8a1cd897"
33
+ "gitHead": "43f790e208d5eea38a8d3f09136dc1221d26ccc3"
34
34
  }
package/readme.md CHANGED
@@ -57,7 +57,8 @@ 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
60
+
61
+ ## Operations
61
62
 
62
63
  > Deployment commands use current `kubectl` context.
63
64
 
@@ -93,3 +94,21 @@ the context will be found and replayed sequentially.
93
94
  </dt>
94
95
  <dd>Print keys and values of a secret.</dd>
95
96
  </dl>
97
+
98
+ ### shell
99
+
100
+ <dl>
101
+ <dt>
102
+ <code>toa shell [image]</code>
103
+ </dt>
104
+ <dd>Run interactive shell inside the current Kubernetes context using disposable pod.
105
+
106
+ <code>image</code> docker image<br/>
107
+ </dd>
108
+ </dl>
109
+
110
+ Extra arguments may be passed:
111
+
112
+ ```shell
113
+ $ toa shell -- ping 1.1
114
+ ```
@@ -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