@ansible-flow/assets 0.88.0 → 0.90.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Ansible Flow Designer files a host passes by path: the Python probe, the run events callback, the JSON schemas, the contract with Ansible Flow Server and the sample projects.
4
4
 
5
- Built from [Ansible Flow Designer](https://github.com/ChistokhinSV/ansible-flow-designer) 0.88.0
5
+ Built from [Ansible Flow Designer](https://github.com/ChistokhinSV/ansible-flow-designer) 0.90.0
6
6
  and released with it. The folders are found by path: `import { probeDir, schemaDir, contractDir, samplesDir } from '@ansible-flow/assets'`.
7
7
 
8
8
  What is in the package, which entry points are documented and what may change:
@@ -11,8 +11,8 @@ Shipped in `@ansible-flow/assets` (`contractDir`).
11
11
 
12
12
  - `world`: what the server holds before the first exchange: people (`users`), access tokens
13
13
  (`tokens`, by name: owner, `readOnly`), one workspace, the owner's grants on it (`grants`), one
14
- project whose repository is the folder `repo/` committed on `branch`, and its launch
15
- configurations.
14
+ project whose repository is the folder `repo/` committed on `branch` (`library`: its subflows
15
+ are offered to every project, AFD-295), and its launch configurations.
16
16
  - `exchanges`, in order. Each has a `request` (`method`, `path`, `token`: a name from
17
17
  `tokens`, none for no sign-in; `body`), the `response` it gets (`status`, `body` pattern) and
18
18
  `capture`: values of the response body kept by name for later paths and patterns
@@ -36,5 +36,6 @@ The `version` at the top changes when a pattern's meaning changes.
36
36
 
37
37
  ## `repo/`
38
38
 
39
- The project's files: a flow (`hello`), an inventory, and a flow in a format newer than any server
40
- reads, which the server must refuse to run.
39
+ The project's files: a flow (`hello`), a flow with a subflow the library offers (`shared`), an
40
+ inventory, and a flow in a format newer than any server reads, which the server must refuse to
41
+ run.
@@ -0,0 +1,61 @@
1
+ # Steps several flows share: a library project offers its subflows to every project (AFD-295).
2
+ schema_version: 2
3
+ flow:
4
+ id: 01M7KT0R3V9Q2N6XW1B8HC5D4E
5
+ key: shared
6
+ name: Shared steps
7
+ version: 1
8
+ goal: "Steps other flows copy from the library: a backup of the configuration."
9
+ inputs:
10
+ devices:
11
+ type: host_list
12
+ required: true
13
+ targets: true
14
+ nodes:
15
+ - id: 01M7KT0R3V9Q2N6XW1B8HC5D4F
16
+ key: start
17
+ type: start
18
+ title: Start
19
+ - id: 01M7KT0R3V9Q2N6XW1B8HC5D4G
20
+ key: done
21
+ type: end
22
+ title: Done
23
+ outcome: success
24
+ - id: 01M7KT0R3V9Q2N6XW1B8HC5D4H
25
+ key: backup
26
+ type: subflow
27
+ title: Back up the configuration
28
+ intent: Read the running configuration and keep it on the controller.
29
+ subflow:
30
+ nodes:
31
+ - id: 01M7KT0R3V9Q2N6XW1B8HC5D4J
32
+ key: read-config
33
+ type: task
34
+ title: Read the configuration
35
+ status: implemented
36
+ impl:
37
+ kind: module
38
+ ref: ansible.builtin.debug
39
+ params:
40
+ msg: Reading the configuration of {{ inventory_hostname }}
41
+ boundary:
42
+ in: 01M7KT0R3V9Q2N6XW1B8HC5D4J
43
+ outputs:
44
+ ok_hosts:
45
+ - node: 01M7KT0R3V9Q2N6XW1B8HC5D4J
46
+ port: ok_hosts
47
+ edges:
48
+ - id: 01M7KT0R3V9Q2N6XW1B8HC5D4K
49
+ from:
50
+ node: 01M7KT0R3V9Q2N6XW1B8HC5D4F
51
+ port: ok_hosts
52
+ to:
53
+ node: 01M7KT0R3V9Q2N6XW1B8HC5D4H
54
+ port: in
55
+ - id: 01M7KT0R3V9Q2N6XW1B8HC5D4M
56
+ from:
57
+ node: 01M7KT0R3V9Q2N6XW1B8HC5D4H
58
+ port: ok_hosts
59
+ to:
60
+ node: 01M7KT0R3V9Q2N6XW1B8HC5D4G
61
+ port: in
@@ -3,30 +3,63 @@
3
3
  "version": 1,
4
4
  "world": {
5
5
  "users": [
6
- { "login": "dana", "name": "Dana Whitfield", "admin": true },
7
- { "login": "omar", "name": "Omar Haddad" }
6
+ {
7
+ "login": "dana",
8
+ "name": "Dana Whitfield",
9
+ "admin": true
10
+ },
11
+ {
12
+ "login": "omar",
13
+ "name": "Omar Haddad"
14
+ }
8
15
  ],
9
16
  "tokens": {
10
- "dana": { "user": "dana" },
11
- "omar": { "user": "omar" },
12
- "omar-read": { "user": "omar", "readOnly": true }
17
+ "dana": {
18
+ "user": "dana"
19
+ },
20
+ "omar": {
21
+ "user": "omar"
22
+ },
23
+ "omar-read": {
24
+ "user": "omar",
25
+ "readOnly": true
26
+ }
27
+ },
28
+ "workspace": {
29
+ "key": "net",
30
+ "name": "Network"
31
+ },
32
+ "grants": [
33
+ {
34
+ "user": "omar",
35
+ "level": "operator"
36
+ }
37
+ ],
38
+ "project": {
39
+ "key": "edge",
40
+ "name": "Edge",
41
+ "branch": "main",
42
+ "files": "repo",
43
+ "library": true
13
44
  },
14
- "workspace": { "key": "net", "name": "Network" },
15
- "grants": [{ "user": "omar", "level": "operator" }],
16
- "project": { "key": "edge", "name": "Edge", "branch": "main", "files": "repo" },
17
45
  "launchConfigs": [
18
46
  {
19
47
  "name": "Hello",
20
48
  "flowFile": "flows/hello.flow.yaml",
21
49
  "inventory": "inventory/hosts.yaml",
22
- "inputs": { "devices": ["fw-edge-01"] }
50
+ "inputs": {
51
+ "devices": ["fw-edge-01"]
52
+ }
23
53
  }
24
54
  ]
25
55
  },
26
56
  "exchanges": [
27
57
  {
28
58
  "name": "what the server is: a client checks it first",
29
- "request": { "method": "GET", "path": "/api/v1/meta" },
59
+ "request": {
60
+ "method": "GET",
61
+ "path": "/api/v1/meta"
62
+ },
30
63
  "response": {
31
64
  "status": 200,
32
65
  "body": {
@@ -37,28 +70,55 @@
37
70
  "designer": {
38
71
  "version": "$string",
39
72
  "format": "$number",
40
- "formats": { "$items": "$number" }
73
+ "formats": {
74
+ "$items": "$number"
75
+ }
41
76
  },
42
- "features": { "$items": "$string" }
77
+ "features": {
78
+ "$items": "$string"
79
+ }
43
80
  }
44
81
  }
45
82
  },
46
83
  {
47
84
  "name": "no token: sign in first",
48
- "request": { "method": "GET", "path": "/api/v1/workspaces" },
49
- "response": { "status": 401, "body": { "error": "unauthorized", "message": "$string" } }
85
+ "request": {
86
+ "method": "GET",
87
+ "path": "/api/v1/workspaces"
88
+ },
89
+ "response": {
90
+ "status": 401,
91
+ "body": {
92
+ "error": "unauthorized",
93
+ "message": "$string"
94
+ }
95
+ }
50
96
  },
51
97
  {
52
98
  "name": "the workspaces the token's owner may see",
53
- "request": { "method": "GET", "path": "/api/v1/workspaces", "token": "omar" },
99
+ "request": {
100
+ "method": "GET",
101
+ "path": "/api/v1/workspaces",
102
+ "token": "omar"
103
+ },
54
104
  "response": {
55
105
  "status": 200,
56
- "body": [{ "id": "$uuid", "key": "net", "name": "Network" }]
106
+ "body": [
107
+ {
108
+ "id": "$uuid",
109
+ "key": "net",
110
+ "name": "Network"
111
+ }
112
+ ]
57
113
  }
58
114
  },
59
115
  {
60
116
  "name": "a workspace's projects: where git reaches each, and the commit a run takes",
61
- "request": { "method": "GET", "path": "/api/v1/workspaces/net/projects", "token": "omar" },
117
+ "request": {
118
+ "method": "GET",
119
+ "path": "/api/v1/workspaces/net/projects",
120
+ "token": "omar"
121
+ },
62
122
  "response": {
63
123
  "status": 200,
64
124
  "body": [
@@ -72,24 +132,114 @@
72
132
  }
73
133
  ]
74
134
  },
75
- "capture": { "project": "0.id", "commit": "0.commit" }
135
+ "capture": {
136
+ "project": "0.id",
137
+ "commit": "0.commit"
138
+ }
76
139
  },
77
140
  {
78
141
  "name": "a project's flows; one in a newer format than the server reads cannot run",
79
- "request": { "method": "GET", "path": "/api/v1/projects/${project}/flows", "token": "omar" },
142
+ "request": {
143
+ "method": "GET",
144
+ "path": "/api/v1/projects/${project}/flows",
145
+ "token": "omar"
146
+ },
80
147
  "response": {
81
148
  "status": 200,
82
149
  "body": {
83
150
  "commit": "${commit}",
84
151
  "flows": [
85
- { "file": "flows/hello.flow.yaml", "ok": true, "key": "hello", "errors": 0 },
152
+ {
153
+ "file": "flows/hello.flow.yaml",
154
+ "ok": true,
155
+ "key": "hello",
156
+ "errors": 0
157
+ },
86
158
  {
87
159
  "file": "flows/next.flow.yaml",
88
160
  "ok": false,
89
- "problem": { "$contains": "Upgrade the server" }
161
+ "problem": {
162
+ "$contains": "Upgrade the server"
163
+ }
164
+ },
165
+ {
166
+ "file": "flows/shared.flow.yaml",
167
+ "ok": true,
168
+ "key": "shared",
169
+ "errors": 0
170
+ }
171
+ ]
172
+ }
173
+ }
174
+ },
175
+ {
176
+ "name": "the library's subflows (AFD-295): those of library projects the token may read",
177
+ "request": {
178
+ "method": "GET",
179
+ "path": "/api/v1/library/subflows",
180
+ "token": "omar"
181
+ },
182
+ "response": {
183
+ "status": 200,
184
+ "body": {
185
+ "subflows": [
186
+ {
187
+ "from": "afs://net/edge/flows/shared.flow.yaml#backup",
188
+ "workspace": "net",
189
+ "project": "edge",
190
+ "file": "flows/shared.flow.yaml",
191
+ "path": "backup",
192
+ "title": "Back up the configuration",
193
+ "flow": "Shared steps",
194
+ "version": 1,
195
+ "commit": "$commit"
90
196
  }
91
197
  ]
92
198
  }
199
+ },
200
+ "capture": {
201
+ "libraryCommit": "subflows.0.commit"
202
+ }
203
+ },
204
+ {
205
+ "name": "one library subflow as it is now, to copy",
206
+ "request": {
207
+ "method": "GET",
208
+ "path": "/api/v1/library/subflow?from=afs%3A%2F%2Fnet%2Fedge%2Fflows%2Fshared.flow.yaml%23backup",
209
+ "token": "omar"
210
+ },
211
+ "response": {
212
+ "status": 200,
213
+ "body": {
214
+ "from": "afs://net/edge/flows/shared.flow.yaml#backup",
215
+ "version": 1,
216
+ "commit": "${libraryCommit}",
217
+ "node": {
218
+ "key": "backup",
219
+ "type": "subflow",
220
+ "title": "Back up the configuration",
221
+ "subflow": {
222
+ "nodes": {
223
+ "$items": "$any"
224
+ }
225
+ }
226
+ }
227
+ }
228
+ }
229
+ },
230
+ {
231
+ "name": "a library subflow that is not there",
232
+ "request": {
233
+ "method": "GET",
234
+ "path": "/api/v1/library/subflow?from=afs%3A%2F%2Fnet%2Fedge%2Fflows%2Fshared.flow.yaml%23gone",
235
+ "token": "omar"
236
+ },
237
+ "response": {
238
+ "status": 404,
239
+ "body": {
240
+ "error": "not_found",
241
+ "message": "$string"
242
+ }
93
243
  }
94
244
  },
95
245
  {
@@ -101,7 +251,11 @@
101
251
  },
102
252
  "response": {
103
253
  "status": 200,
104
- "body": { "from": "${commit}", "to": "${commit}", "flows": [] }
254
+ "body": {
255
+ "from": "${commit}",
256
+ "to": "${commit}",
257
+ "flows": []
258
+ }
105
259
  }
106
260
  },
107
261
  {
@@ -113,7 +267,10 @@
113
267
  },
114
268
  "response": {
115
269
  "status": 409,
116
- "body": { "error": "unknown_commit", "message": "$string" }
270
+ "body": {
271
+ "error": "unknown_commit",
272
+ "message": "$string"
273
+ }
117
274
  }
118
275
  },
119
276
  {
@@ -135,7 +292,9 @@
135
292
  }
136
293
  ]
137
294
  },
138
- "capture": { "config": "0.id" }
295
+ "capture": {
296
+ "config": "0.id"
297
+ }
139
298
  },
140
299
  {
141
300
  "name": "what a launch would run",
@@ -143,18 +302,30 @@
143
302
  "method": "POST",
144
303
  "path": "/api/v1/launch-configs/${config}/check",
145
304
  "token": "omar",
146
- "body": { "mode": "check" }
305
+ "body": {
306
+ "mode": "check"
307
+ }
147
308
  },
148
309
  "response": {
149
310
  "status": 200,
150
311
  "body": {
151
312
  "launch": {
152
313
  "commit": "${commit}",
153
- "flow": { "file": "flows/hello.flow.yaml", "key": "hello", "name": "Hello, Ansible" },
314
+ "flow": {
315
+ "file": "flows/hello.flow.yaml",
316
+ "key": "hello",
317
+ "name": "Hello, Ansible"
318
+ },
154
319
  "mode": "check",
155
320
  "targets": ["fw-edge-01"]
156
321
  },
157
- "form": { "fields": { "$items": { "name": "$string" } } }
322
+ "form": {
323
+ "fields": {
324
+ "$items": {
325
+ "name": "$string"
326
+ }
327
+ }
328
+ }
158
329
  }
159
330
  }
160
331
  },
@@ -164,14 +335,23 @@
164
335
  "method": "POST",
165
336
  "path": "/api/v1/launch-configs/${config}/check",
166
337
  "token": "omar",
167
- "body": { "inputs": { "devices": "" } }
338
+ "body": {
339
+ "inputs": {
340
+ "devices": ""
341
+ }
342
+ }
168
343
  },
169
344
  "response": {
170
345
  "status": 422,
171
346
  "body": {
172
347
  "error": "$string",
173
348
  "message": "$string",
174
- "problems": [{ "field": "devices", "message": "$string" }]
349
+ "problems": [
350
+ {
351
+ "field": "devices",
352
+ "message": "$string"
353
+ }
354
+ ]
175
355
  }
176
356
  }
177
357
  },
@@ -183,7 +363,13 @@
183
363
  "token": "omar-read",
184
364
  "body": {}
185
365
  },
186
- "response": { "status": 403, "body": { "error": "read_only_token", "message": "$string" } }
366
+ "response": {
367
+ "status": 403,
368
+ "body": {
369
+ "error": "read_only_token",
370
+ "message": "$string"
371
+ }
372
+ }
187
373
  },
188
374
  {
189
375
  "name": "launch: the run is queued",
@@ -191,7 +377,9 @@
191
377
  "method": "POST",
192
378
  "path": "/api/v1/launch-configs/${config}/launch",
193
379
  "token": "omar",
194
- "body": { "mode": "check" }
380
+ "body": {
381
+ "mode": "check"
382
+ }
195
383
  },
196
384
  "response": {
197
385
  "status": 201,
@@ -200,34 +388,66 @@
200
388
  "number": 1,
201
389
  "project": "${project}",
202
390
  "commit": "${commit}",
203
- "flow": { "file": "flows/hello.flow.yaml", "key": "hello" },
391
+ "flow": {
392
+ "file": "flows/hello.flow.yaml",
393
+ "key": "hello"
394
+ },
204
395
  "mode": "check",
205
396
  "state": "queued",
206
- "requestedBy": { "login": "omar" },
397
+ "requestedBy": {
398
+ "login": "omar"
399
+ },
207
400
  "createdAt": "$time"
208
401
  }
209
402
  },
210
- "capture": { "run": "id" }
403
+ "capture": {
404
+ "run": "id"
405
+ }
211
406
  },
212
407
  {
213
408
  "name": "a run, as it stands",
214
- "request": { "method": "GET", "path": "/api/v1/runs/${run}", "token": "omar" },
409
+ "request": {
410
+ "method": "GET",
411
+ "path": "/api/v1/runs/${run}",
412
+ "token": "omar"
413
+ },
215
414
  "response": {
216
415
  "status": 200,
217
- "body": { "id": "${run}", "number": 1, "state": "queued", "attempts": 0 }
416
+ "body": {
417
+ "id": "${run}",
418
+ "number": 1,
419
+ "state": "queued",
420
+ "attempts": 0
421
+ }
218
422
  }
219
423
  },
220
424
  {
221
425
  "name": "a run's approvals (none reached yet)",
222
- "request": { "method": "GET", "path": "/api/v1/runs/${run}/approvals", "token": "omar" },
223
- "response": { "status": 200, "body": [] }
426
+ "request": {
427
+ "method": "GET",
428
+ "path": "/api/v1/runs/${run}/approvals",
429
+ "token": "omar"
430
+ },
431
+ "response": {
432
+ "status": 200,
433
+ "body": []
434
+ }
224
435
  },
225
436
  {
226
437
  "name": "stop a run that has not started: it is cancelled at once",
227
- "request": { "method": "POST", "path": "/api/v1/runs/${run}/cancel", "token": "omar" },
438
+ "request": {
439
+ "method": "POST",
440
+ "path": "/api/v1/runs/${run}/cancel",
441
+ "token": "omar"
442
+ },
228
443
  "response": {
229
444
  "status": 202,
230
- "body": { "id": "${run}", "state": "cancelled", "cancelledBy": "omar", "endedAt": "$time" }
445
+ "body": {
446
+ "id": "${run}",
447
+ "state": "cancelled",
448
+ "cancelledBy": "omar",
449
+ "endedAt": "$time"
450
+ }
231
451
  }
232
452
  },
233
453
  {
@@ -237,7 +457,13 @@
237
457
  "path": "/api/v1/runs/00000000-0000-4000-8000-000000000000",
238
458
  "token": "omar"
239
459
  },
240
- "response": { "status": 404, "body": { "error": "not_found", "message": "$string" } }
460
+ "response": {
461
+ "status": 404,
462
+ "body": {
463
+ "error": "not_found",
464
+ "message": "$string"
465
+ }
466
+ }
241
467
  },
242
468
  {
243
469
  "name": "a launch configuration of a flow in a newer format is refused, at its field",
@@ -245,14 +471,19 @@
245
471
  "method": "POST",
246
472
  "path": "/api/v1/projects/${project}/launch-configs",
247
473
  "token": "dana",
248
- "body": { "name": "Next", "flowFile": "flows/next.flow.yaml" }
474
+ "body": {
475
+ "name": "Next",
476
+ "flowFile": "flows/next.flow.yaml"
477
+ }
249
478
  },
250
479
  "response": {
251
480
  "status": 400,
252
481
  "body": {
253
482
  "error": "invalid",
254
483
  "field": "flowFile",
255
- "message": { "$contains": "Upgrade the server" }
484
+ "message": {
485
+ "$contains": "Upgrade the server"
486
+ }
256
487
  }
257
488
  }
258
489
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ansible-flow/assets",
3
- "version": "0.88.0",
3
+ "version": "0.90.0",
4
4
  "description": "Ansible Flow Designer files a host passes by path: the Python probe, the run events callback, the JSON schemas, the contract with Ansible Flow Server and the sample projects.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/ChistokhinSV/ansible-flow-designer/blob/main/docs/packages.md",