@toa.io/extensions.origins 0.20.0-dev.2 → 0.20.0-dev.21
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 +7 -7
- package/readme.md +3 -2
- package/source/.credentials.js +7 -1
- package/source/deployment.test.js +0 -10
- package/source/manifest.test.js +0 -6
- package/source/protocols/amqp/.test/mock.comq.js +2 -2
- package/source/protocols/amqp/aspect.js +2 -2
- package/source/protocols/amqp/aspect.test.js +6 -6
- package/source/protocols/amqp/deployment.js +8 -2
- package/source/schemas/manifest.cos.yaml +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/extensions.origins",
|
|
3
|
-
"version": "0.20.0-dev.
|
|
3
|
+
"version": "0.20.0-dev.21",
|
|
4
4
|
"description": "Toa Origins",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@toa.io/core": "0.20.0-dev.
|
|
23
|
-
"@toa.io/generic": "0.20.0-dev.
|
|
24
|
-
"@toa.io/schemas": "0.20.0-dev.
|
|
25
|
-
"@toa.io/yaml": "0.20.0-dev.
|
|
26
|
-
"comq": "0.
|
|
22
|
+
"@toa.io/core": "0.20.0-dev.21",
|
|
23
|
+
"@toa.io/generic": "0.20.0-dev.21",
|
|
24
|
+
"@toa.io/schemas": "0.20.0-dev.21",
|
|
25
|
+
"@toa.io/yaml": "0.20.0-dev.21",
|
|
26
|
+
"comq": "0.8.0",
|
|
27
27
|
"node-fetch": "2.6.7"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node-fetch": "2.6.2"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "7dbe313e05e714e35401adb5f0507e140f3f1215"
|
|
33
33
|
}
|
package/readme.md
CHANGED
|
@@ -125,6 +125,7 @@ and `password`.
|
|
|
125
125
|
|
|
126
126
|
```shell
|
|
127
127
|
# deploy credentials to the current kubectl context
|
|
128
|
-
$ toa conceal origins-dummies-dummiy-messages username
|
|
129
|
-
$ toa conceal origins-dummies-dummiy-messages password secret
|
|
128
|
+
$ toa conceal origins-dummies-dummiy-messages username=developer password=secret
|
|
130
129
|
```
|
|
130
|
+
|
|
131
|
+
See [`toa conceal`](/runtime/cli/readme.md#conceal).
|
package/source/.credentials.js
CHANGED
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
function check (reference) {
|
|
7
7
|
if (typeof reference !== 'string') return // aspect properties object
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
let url
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
url = new URL(reference)
|
|
13
|
+
} catch {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
10
16
|
|
|
11
17
|
if (url.username !== '' || url.password !== '') throw new Error('Origins must not contain credentials. Please use environment secrets instead.')
|
|
12
18
|
}
|
|
@@ -62,16 +62,6 @@ describe('validation', () => {
|
|
|
62
62
|
|
|
63
63
|
expect(() => deployment(components, annotations)).toThrow('must be object')
|
|
64
64
|
})
|
|
65
|
-
|
|
66
|
-
it('should throw if annotation is URI is not valid', async () => {
|
|
67
|
-
const annotations = {
|
|
68
|
-
[component.locator.id]: {
|
|
69
|
-
[origin]: 'hello!'
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
expect(() => deployment(components, annotations)).toThrow('must match format')
|
|
74
|
-
})
|
|
75
65
|
})
|
|
76
66
|
|
|
77
67
|
it('should create variables', () => {
|
package/source/manifest.test.js
CHANGED
|
@@ -32,12 +32,6 @@ it('should pass if valid', async () => {
|
|
|
32
32
|
expect(() => manifest(input)).not.toThrow()
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
it('should fail if not uri', async () => {
|
|
36
|
-
const input = { [generate()]: generate() }
|
|
37
|
-
|
|
38
|
-
expect(() => manifest(input)).toThrow('must match format')
|
|
39
|
-
})
|
|
40
|
-
|
|
41
35
|
it('should throw if protocol is not supported', async () => {
|
|
42
36
|
const input = { foo: 'wat://' + generate() }
|
|
43
37
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { generate } = require('randomstring')
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const assert = jest.fn(async () => ({
|
|
6
6
|
emit: jest.fn(async () => undefined),
|
|
7
7
|
request: jest.fn(async () => generate()),
|
|
8
8
|
reply: jest.fn(async () => undefined),
|
|
@@ -10,4 +10,4 @@ const connect = jest.fn(async () => ({
|
|
|
10
10
|
close: jest.fn(async () => undefined)
|
|
11
11
|
}))
|
|
12
12
|
|
|
13
|
-
exports.
|
|
13
|
+
exports.assert = assert
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { assert } = require('comq')
|
|
4
4
|
const { Connector } = require('@toa.io/core')
|
|
5
5
|
const { shards } = require('@toa.io/generic')
|
|
6
6
|
|
|
@@ -44,7 +44,7 @@ class Aspect extends Connector {
|
|
|
44
44
|
|
|
45
45
|
#open = async ([origin, reference]) => {
|
|
46
46
|
const references = shards(reference)
|
|
47
|
-
const io = await
|
|
47
|
+
const io = await assert(...references)
|
|
48
48
|
|
|
49
49
|
this.#origins[origin] = restrict(io)
|
|
50
50
|
}
|
|
@@ -41,7 +41,7 @@ it('should connect', async () => {
|
|
|
41
41
|
await aspect.open()
|
|
42
42
|
|
|
43
43
|
for (const reference of Object.values(manifest)) {
|
|
44
|
-
expect(comq.
|
|
44
|
+
expect(comq.assert).toHaveBeenCalledWith(reference)
|
|
45
45
|
}
|
|
46
46
|
})
|
|
47
47
|
|
|
@@ -60,7 +60,7 @@ it('should connect to shards', async () => {
|
|
|
60
60
|
|
|
61
61
|
await aspect.open()
|
|
62
62
|
|
|
63
|
-
expect(comq.
|
|
63
|
+
expect(comq.assert).toHaveBeenCalledWith(...shards)
|
|
64
64
|
})
|
|
65
65
|
|
|
66
66
|
it('should disconnect', async () => {
|
|
@@ -68,8 +68,8 @@ it('should disconnect', async () => {
|
|
|
68
68
|
await aspect.close()
|
|
69
69
|
|
|
70
70
|
for (const reference of Object.values(manifest)) {
|
|
71
|
-
const index = comq.
|
|
72
|
-
const io = await comq.
|
|
71
|
+
const index = comq.assert.mock.calls.findIndex((call) => call[0] === reference)
|
|
72
|
+
const io = await comq.assert.mock.results[index].value
|
|
73
73
|
|
|
74
74
|
expect(io.close).toHaveBeenCalled()
|
|
75
75
|
}
|
|
@@ -92,9 +92,9 @@ describe('invoke', () => {
|
|
|
92
92
|
origin = sample(origins)
|
|
93
93
|
|
|
94
94
|
const reference = manifest[origin]
|
|
95
|
-
const index = comq.
|
|
95
|
+
const index = comq.assert.mock.calls.findIndex((call) => call[0] === reference)
|
|
96
96
|
|
|
97
|
-
io = await comq.
|
|
97
|
+
io = await comq.assert.mock.results[index].value
|
|
98
98
|
args = [generate(), generate(), generate()]
|
|
99
99
|
})
|
|
100
100
|
|
|
@@ -15,9 +15,13 @@ function deployment (instances) {
|
|
|
15
15
|
const secrets = []
|
|
16
16
|
|
|
17
17
|
for (const [origin, reference] of Object.entries(manifest)) {
|
|
18
|
-
|
|
18
|
+
let protocol
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const match = reference.match(RX)
|
|
21
|
+
|
|
22
|
+
if (match !== null) protocol = match.groups.protocol
|
|
23
|
+
|
|
24
|
+
if (protocols.includes(protocol)) {
|
|
21
25
|
const originSecrets = createSecrets(locator, origin)
|
|
22
26
|
|
|
23
27
|
secrets.push(...originSecrets)
|
|
@@ -60,4 +64,6 @@ function createSecret (locator, origin, property) {
|
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
const RX = /^(?<protocol>\w{1,12}:)/
|
|
68
|
+
|
|
63
69
|
exports.deployment = deployment
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/^\./: <boolean>
|
|
2
|
-
/^[
|
|
2
|
+
/^[a-zA-Z0-9]{1,32}$/: string
|