@toa.io/cli 1.0.0-alpha.50 → 1.0.0-alpha.52

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.0.0-alpha.50",
3
+ "version": "1.0.0-alpha.52",
4
4
  "description": "Toa CLI",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -22,17 +22,17 @@
22
22
  "@toa.io/runtime": "*"
23
23
  },
24
24
  "dependencies": {
25
- "@toa.io/console": "1.0.0-alpha.50",
26
- "@toa.io/generic": "1.0.0-alpha.50",
27
- "@toa.io/kubernetes": "1.0.0-alpha.50",
28
- "@toa.io/norm": "1.0.0-alpha.50",
29
- "@toa.io/operations": "1.0.0-alpha.50",
30
- "@toa.io/yaml": "1.0.0-alpha.50",
25
+ "@toa.io/console": "1.0.0-alpha.52",
26
+ "@toa.io/generic": "1.0.0-alpha.52",
27
+ "@toa.io/kubernetes": "1.0.0-alpha.52",
28
+ "@toa.io/norm": "1.0.0-alpha.52",
29
+ "@toa.io/operations": "1.0.0-alpha.52",
30
+ "@toa.io/yaml": "1.0.0-alpha.52",
31
31
  "dotenv": "16.1.1",
32
32
  "find-up": "5.0.0",
33
33
  "jsonpath": "1.1.1",
34
34
  "paseto": "3.1.4",
35
35
  "yargs": "17.6.2"
36
36
  },
37
- "gitHead": "514269d4b481150c8cd0db2e5971da6e9fe80ad9"
37
+ "gitHead": "074291add0a7ac4bf2172e3841d6b480de8bd88d"
38
38
  }
package/readme.md CHANGED
@@ -73,6 +73,16 @@ Credentials specified in the output file are preserved.
73
73
  </dd>
74
74
  </dl>
75
75
 
76
+ ### export secrets
77
+
78
+ <dl>
79
+ <dt><code>toa export secrets &lt;environment&gt;</code></dt>
80
+ <dd>Print deployment secrets.
81
+
82
+ <code>--path</code> path to context (default <code>.</code>)<br/>
83
+ </dd>
84
+ </dl>
85
+
76
86
  ## Operations
77
87
 
78
88
  > Some commands use current `kubectl` and `docker` context.
@@ -0,0 +1,23 @@
1
+ 'use strict'
2
+
3
+ const { secrets } = require('../../handlers/export/secrets')
4
+
5
+ const builder = (yargs) => {
6
+ yargs
7
+ .positional('environment', {
8
+ type: 'string',
9
+ desc: 'Deployment environment'
10
+ })
11
+ .option('path', {
12
+ alias: 'p',
13
+ group: 'Command options:',
14
+ type: 'string',
15
+ desc: 'Path to context',
16
+ default: '.'
17
+ })
18
+ }
19
+
20
+ exports.command = ['secrets <environment>']
21
+ exports.desc = 'Export deployment secrets'
22
+ exports.builder = builder
23
+ exports.handler = secrets
@@ -0,0 +1,41 @@
1
+ 'use strict'
2
+
3
+ const { console } = require('@toa.io/console')
4
+ const { context: find } = require('../../util/find')
5
+ const { deployment: { Factory } } = require('@toa.io/operations')
6
+
7
+ /**
8
+ * @param {{ path: string, target: string, environment?: string }} argv
9
+ * @returns {Promise<void>}
10
+ */
11
+ const secrets = async (argv) => {
12
+ const path = find(argv.path)
13
+ const factory = await Factory.create(path, argv.environment)
14
+ const operator = factory.operator()
15
+ const secrets = operator
16
+ .variables()
17
+ .filter(({ secret }) => secret !== undefined)
18
+ .map(({ secret }) => secret)
19
+ .sort((a, b) => a.name.localeCompare(b.name))
20
+
21
+ const groups = []
22
+ let current = null
23
+
24
+ for (const secret of secrets) {
25
+ if (current === null || current.name !== secret.name) {
26
+ current = { name: secret.name, keys: new Map() }
27
+ groups.push(current)
28
+ }
29
+
30
+ current.keys.set(secret.key, secret.optional)
31
+ }
32
+
33
+ for (const group of groups) {
34
+ console.log(`${group.name}:`)
35
+
36
+ for (const [key, optional] of group.keys)
37
+ console.log(' ' + key + (optional ? ' (optional)' : ''))
38
+ }
39
+ }
40
+
41
+ exports.secrets = secrets