Skip to content
This repository was archived by the owner on Dec 2, 2022. It is now read-only.

Commit fdc2111

Browse files
authored
Replace meta version with galaxy_info.standalone (#387)
As ansible does not allow adding new properties as root of meta files, we introduce a `galaxy_info.standalone` field, of type bool, so we can distinguish between a standalone role and a collection one.
1 parent 20f13a9 commit fdc2111

File tree

13 files changed

+179
-145
lines changed

13 files changed

+179
-145
lines changed

f/ansible-meta.json

Lines changed: 47 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,19 @@
400400
"title": "FreeBSDPlatformModel",
401401
"type": "object"
402402
},
403-
"GalaxyInfoModel-v1": {
403+
"GalaxyInfoModel": {
404404
"additionalProperties": false,
405+
"else": {
406+
"$comment": "If standalone is false, then we have a collection role and only description is required",
407+
"required": ["description"]
408+
},
409+
"if": {
410+
"properties": {
411+
"standalone": {
412+
"const": true
413+
}
414+
}
415+
},
405416
"properties": {
406417
"author": {
407418
"title": "Author",
@@ -454,14 +465,23 @@
454465
"pattern": "^[a-z][a-z0-9_]+$",
455466
"title": "Role Name",
456467
"type": "string"
468+
},
469+
"standalone": {
470+
"description:": "Set to true for old standalone roles, or false for new collection roles.",
471+
"title": "Standalone",
472+
"type": "boolean"
457473
}
458474
},
459-
"required": [
460-
"description",
461-
"license",
462-
"min_ansible_version",
463-
"platforms"
464-
],
475+
"then": {
476+
"$comment": "Standalone role, so we require several fields.",
477+
"required": [
478+
"standalone",
479+
"description",
480+
"license",
481+
"min_ansible_version",
482+
"platforms"
483+
]
484+
},
465485
"title": "GalaxyInfoModel for old standalone role (v1)",
466486
"type": "object"
467487
},
@@ -486,7 +506,8 @@
486506
},
487507
"platforms": {
488508
"$ref": "#/$defs/platforms"
489-
}
509+
},
510+
"standalone": { "const": false }
490511
},
491512
"required": ["description"],
492513
"title": "GalaxyInfoModel for role within a collection (v2)",
@@ -1281,79 +1302,6 @@
12811302
"title": "Platforms",
12821303
"type": "array"
12831304
},
1284-
"v1": {
1285-
"additionalProperties": false,
1286-
"properties": {
1287-
"allow_duplicates": {
1288-
"title": "Allow Duplicates",
1289-
"type": "boolean"
1290-
},
1291-
"cloud_platforms": {
1292-
"items": {
1293-
"enum": [
1294-
"amazon",
1295-
"azure",
1296-
"centurylink",
1297-
"google",
1298-
"openstack",
1299-
"ovirt",
1300-
"rackspace",
1301-
"vmware"
1302-
],
1303-
"type": "string"
1304-
},
1305-
"markdownDescription": "Which cloud platforms are supported, existing values can be gathered using the [API](https://galaxy.ansible.com/api/v1/cloud_platforms/)",
1306-
"title": "Cloud Platforms",
1307-
"type": "array"
1308-
},
1309-
"collections": {
1310-
"$ref": "#/$defs/collections"
1311-
},
1312-
"dependencies": {
1313-
"items": {
1314-
"$ref": "#/$defs/DependencyModel"
1315-
},
1316-
"title": "Dependencies",
1317-
"type": "array"
1318-
},
1319-
"galaxy_info": {
1320-
"$ref": "#/$defs/GalaxyInfoModel-v1"
1321-
},
1322-
"version": {
1323-
"const": 1
1324-
}
1325-
},
1326-
"required": ["version"],
1327-
"title": "Meta Schema v1 (standalone role)",
1328-
"type": "object"
1329-
},
1330-
"v2": {
1331-
"additionalProperties": false,
1332-
"properties": {
1333-
"allow_duplicates": {
1334-
"title": "Allow Duplicates",
1335-
"type": "boolean"
1336-
},
1337-
"collections": {
1338-
"$ref": "#/$defs/collections"
1339-
},
1340-
"dependencies": {
1341-
"items": {
1342-
"$ref": "#/$defs/DependencyModel"
1343-
},
1344-
"title": "Dependencies",
1345-
"type": "array"
1346-
},
1347-
"galaxy_info": {
1348-
"$ref": "#/$defs/GalaxyInfoModel-v2"
1349-
},
1350-
"version": {
1351-
"const": 2
1352-
}
1353-
},
1354-
"title": "Meta Schema v2 (role inside collection)",
1355-
"type": "object"
1356-
},
13571305
"vCenterPlatformModel": {
13581306
"properties": {
13591307
"name": {
@@ -1395,26 +1343,28 @@
13951343
},
13961344
"$id": "https://raw.githubusercontent.com/ansible/schemas/main/f/ansible-meta.json",
13971345
"$schema": "http://json-schema.org/draft-07/schema",
1398-
"else": {
1399-
"$ref": "#/$defs/v2"
1400-
},
14011346
"examples": ["meta/main.yml"],
1402-
"if": {
1403-
"properties": {
1404-
"version": {
1405-
"const": 1
1406-
}
1407-
}
1408-
},
14091347
"properties": {
1410-
"version": {
1411-
"enum": [1, 2],
1412-
"type": "integer"
1348+
"additionalProperties": false,
1349+
"allow_duplicates": {
1350+
"title": "Allow Duplicates",
1351+
"type": "boolean"
1352+
},
1353+
"collections": {
1354+
"$ref": "#/$defs/collections"
1355+
},
1356+
"dependencies": {
1357+
"items": {
1358+
"$ref": "#/$defs/DependencyModel"
1359+
},
1360+
"title": "Dependencies",
1361+
"type": "array"
1362+
},
1363+
"galaxy_info": {
1364+
"$ref": "#/$defs/GalaxyInfoModel"
14131365
}
14141366
},
1415-
"then": {
1416-
"$ref": "#/$defs/v1"
1417-
},
1367+
"required": ["galaxy_info"],
14181368
"title": "Ansible Meta Schema v1/v2",
14191369
"type": "object"
14201370
}

negative_test/roles/empty_meta/meta/main.yml.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,6 @@
22

33
```json
44
[
5-
{
6-
"instancePath": "",
7-
"keyword": "type",
8-
"message": "must be object",
9-
"params": {
10-
"type": "object"
11-
},
12-
"schemaPath": "#/type"
13-
},
14-
{
15-
"instancePath": "",
16-
"keyword": "if",
17-
"message": "must match \"then\" schema",
18-
"params": {
19-
"failingKeyword": "then"
20-
},
21-
"schemaPath": "#/if"
22-
},
235
{
246
"instancePath": "",
257
"keyword": "type",
@@ -40,12 +22,6 @@ stdout:
4022
{
4123
"status": "fail",
4224
"errors": [
43-
{
44-
"filename": "negative_test/roles/empty_meta/meta/main.yml",
45-
"path": "$",
46-
"message": "None is not of type 'object'",
47-
"has_sub_errors": false
48-
},
4925
{
5026
"filename": "negative_test/roles/empty_meta/meta/main.yml",
5127
"path": "$",

negative_test/roles/meta/main.yml.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,31 @@
33
```json
44
[
55
{
6-
"instancePath": "/galaxy_info/galaxy_tags",
7-
"keyword": "type",
8-
"message": "must be array",
6+
"instancePath": "/galaxy_info",
7+
"keyword": "required",
8+
"message": "must have required property 'standalone'",
99
"params": {
10-
"type": "array"
10+
"missingProperty": "standalone"
1111
},
12-
"schemaPath": "#/properties/galaxy_tags/type"
12+
"schemaPath": "#/then/required"
1313
},
1414
{
15-
"instancePath": "",
15+
"instancePath": "/galaxy_info",
1616
"keyword": "if",
1717
"message": "must match \"then\" schema",
1818
"params": {
1919
"failingKeyword": "then"
2020
},
2121
"schemaPath": "#/if"
22+
},
23+
{
24+
"instancePath": "/galaxy_info/galaxy_tags",
25+
"keyword": "type",
26+
"message": "must be array",
27+
"params": {
28+
"type": "array"
29+
},
30+
"schemaPath": "#/properties/galaxy_tags/type"
2231
}
2332
]
2433
```
@@ -31,6 +40,12 @@ stdout:
3140
{
3241
"status": "fail",
3342
"errors": [
43+
{
44+
"filename": "negative_test/roles/meta/main.yml",
45+
"path": "$.galaxy_info",
46+
"message": "'standalone' is a required property",
47+
"has_sub_errors": false
48+
},
3449
{
3550
"filename": "negative_test/roles/meta/main.yml",
3651
"path": "$.galaxy_info.galaxy_tags",

negative_test/roles/meta_invalid_collection/meta/main.yml.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,29 @@
1212
"schemaPath": "#/$defs/collections/items/pattern"
1313
},
1414
{
15-
"instancePath": "",
15+
"instancePath": "/galaxy_info",
16+
"keyword": "required",
17+
"message": "must have required property 'standalone'",
18+
"params": {
19+
"missingProperty": "standalone"
20+
},
21+
"schemaPath": "#/then/required"
22+
},
23+
{
24+
"instancePath": "/galaxy_info",
25+
"keyword": "required",
26+
"message": "must have required property 'min_ansible_version'",
27+
"params": {
28+
"missingProperty": "min_ansible_version"
29+
},
30+
"schemaPath": "#/then/required"
31+
},
32+
{
33+
"instancePath": "/galaxy_info",
1634
"keyword": "if",
17-
"message": "must match \"else\" schema",
35+
"message": "must match \"then\" schema",
1836
"params": {
19-
"failingKeyword": "else"
37+
"failingKeyword": "then"
2038
},
2139
"schemaPath": "#/if"
2240
}
@@ -36,6 +54,18 @@ stdout:
3654
"path": "$.collections[0]",
3755
"message": "'foo' does not match '^[a-z_]+\\\\.[a-z_]+$'",
3856
"has_sub_errors": false
57+
},
58+
{
59+
"filename": "negative_test/roles/meta_invalid_collection/meta/main.yml",
60+
"path": "$.galaxy_info",
61+
"message": "'standalone' is a required property",
62+
"has_sub_errors": false
63+
},
64+
{
65+
"filename": "negative_test/roles/meta_invalid_collection/meta/main.yml",
66+
"path": "$.galaxy_info",
67+
"message": "'min_ansible_version' is a required property",
68+
"has_sub_errors": false
3969
}
4070
],
4171
"parse_errors": []

negative_test/roles/meta_invalid_collections/meta/main.yml.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,29 @@
1212
"schemaPath": "#/$defs/collections/items/pattern"
1313
},
1414
{
15-
"instancePath": "",
15+
"instancePath": "/galaxy_info",
16+
"keyword": "required",
17+
"message": "must have required property 'standalone'",
18+
"params": {
19+
"missingProperty": "standalone"
20+
},
21+
"schemaPath": "#/then/required"
22+
},
23+
{
24+
"instancePath": "/galaxy_info",
25+
"keyword": "required",
26+
"message": "must have required property 'min_ansible_version'",
27+
"params": {
28+
"missingProperty": "min_ansible_version"
29+
},
30+
"schemaPath": "#/then/required"
31+
},
32+
{
33+
"instancePath": "/galaxy_info",
1634
"keyword": "if",
17-
"message": "must match \"else\" schema",
35+
"message": "must match \"then\" schema",
1836
"params": {
19-
"failingKeyword": "else"
37+
"failingKeyword": "then"
2038
},
2139
"schemaPath": "#/if"
2240
}
@@ -36,6 +54,18 @@ stdout:
3654
"path": "$.collections[0]",
3755
"message": "'FOO.BAR' does not match '^[a-z_]+\\\\.[a-z_]+$'",
3856
"has_sub_errors": false
57+
},
58+
{
59+
"filename": "negative_test/roles/meta_invalid_collections/meta/main.yml",
60+
"path": "$.galaxy_info",
61+
"message": "'standalone' is a required property",
62+
"has_sub_errors": false
63+
},
64+
{
65+
"filename": "negative_test/roles/meta_invalid_collections/meta/main.yml",
66+
"path": "$.galaxy_info",
67+
"message": "'min_ansible_version' is a required property",
68+
"has_sub_errors": false
3969
}
4070
],
4171
"parse_errors": []

0 commit comments

Comments
 (0)