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

Commit 069dcca

Browse files
authored
meta: make the standalone field optional (#389)
1 parent 68da105 commit 069dcca

File tree

16 files changed

+180
-112
lines changed

16 files changed

+180
-112
lines changed

f/ansible-meta.json

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -402,17 +402,54 @@
402402
},
403403
"GalaxyInfoModel": {
404404
"additionalProperties": false,
405+
"allOf": [
406+
{
407+
"if": {
408+
"properties": {
409+
"standalone": {
410+
"const": true
411+
}
412+
}
413+
},
414+
"then": {
415+
"$comment": "Standalone role, so we require several fields.",
416+
"required": [
417+
"author",
418+
"standalone",
419+
"description",
420+
"license",
421+
"min_ansible_version"
422+
]
423+
}
424+
},
425+
{
426+
"if": {
427+
"properties": {
428+
"standalone": {
429+
"const": false
430+
}
431+
}
432+
},
433+
"then": {
434+
"$comment": "Collection roles do not use most galaxy fields.",
435+
"not": {
436+
"required": [
437+
"cloud_platforms",
438+
"galaxy_tags",
439+
"min_ansible_version",
440+
"namespace",
441+
"platforms",
442+
"role_name"
443+
]
444+
},
445+
"required": ["standalone", "description"]
446+
}
447+
}
448+
],
405449
"else": {
406450
"$comment": "If standalone is false, then we have a collection role and only description is required",
407451
"required": ["description"]
408452
},
409-
"if": {
410-
"properties": {
411-
"standalone": {
412-
"const": true
413-
}
414-
}
415-
},
416453
"properties": {
417454
"author": {
418455
"title": "Author",
@@ -472,17 +509,7 @@
472509
"type": "boolean"
473510
}
474511
},
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-
},
485-
"title": "GalaxyInfoModel for old standalone role (v1)",
512+
"title": "GalaxyInfoModel",
486513
"type": "object"
487514
},
488515
"GalaxyInfoModel-v2": {

negative_test/roles/meta/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: 1
21
galaxy_info:
32
description: bar
43
min_ansible_version: "2.9"

negative_test/roles/meta/main.yml.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22

33
```json
44
[
5+
{
6+
"instancePath": "/galaxy_info",
7+
"keyword": "required",
8+
"message": "must have required property 'author'",
9+
"params": {
10+
"missingProperty": "author"
11+
},
12+
"schemaPath": "#/allOf/0/then/required"
13+
},
514
{
615
"instancePath": "/galaxy_info",
716
"keyword": "required",
817
"message": "must have required property 'standalone'",
918
"params": {
1019
"missingProperty": "standalone"
1120
},
12-
"schemaPath": "#/then/required"
21+
"schemaPath": "#/allOf/0/then/required"
1322
},
1423
{
1524
"instancePath": "/galaxy_info",
@@ -18,7 +27,25 @@
1827
"params": {
1928
"failingKeyword": "then"
2029
},
21-
"schemaPath": "#/if"
30+
"schemaPath": "#/allOf/0/if"
31+
},
32+
{
33+
"instancePath": "/galaxy_info",
34+
"keyword": "required",
35+
"message": "must have required property 'standalone'",
36+
"params": {
37+
"missingProperty": "standalone"
38+
},
39+
"schemaPath": "#/allOf/1/then/required"
40+
},
41+
{
42+
"instancePath": "/galaxy_info",
43+
"keyword": "if",
44+
"message": "must match \"then\" schema",
45+
"params": {
46+
"failingKeyword": "then"
47+
},
48+
"schemaPath": "#/allOf/1/if"
2249
},
2350
{
2451
"instancePath": "/galaxy_info/galaxy_tags",
@@ -40,6 +67,18 @@ stdout:
4067
{
4168
"status": "fail",
4269
"errors": [
70+
{
71+
"filename": "negative_test/roles/meta/main.yml",
72+
"path": "$.galaxy_info",
73+
"message": "'author' is a required property",
74+
"has_sub_errors": false
75+
},
76+
{
77+
"filename": "negative_test/roles/meta/main.yml",
78+
"path": "$.galaxy_info",
79+
"message": "'standalone' is a required property",
80+
"has_sub_errors": false
81+
},
4382
{
4483
"filename": "negative_test/roles/meta/main.yml",
4584
"path": "$.galaxy_info",

negative_test/roles/meta_invalid_collection/meta/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
version: 2 # <-- role inside a collection
21
collections:
32
- foo # invalid pattern
43
galaxy_info:
4+
standalone: false # role inside a collection
55
description: foo
66
license: bar
77
platforms:

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,6 @@
1010
"pattern": "^[a-z_]+\\.[a-z_]+$"
1111
},
1212
"schemaPath": "#/$defs/collections/items/pattern"
13-
},
14-
{
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",
34-
"keyword": "if",
35-
"message": "must match \"then\" schema",
36-
"params": {
37-
"failingKeyword": "then"
38-
},
39-
"schemaPath": "#/if"
4013
}
4114
]
4215
```
@@ -54,18 +27,6 @@ stdout:
5427
"path": "$.collections[0]",
5528
"message": "'foo' does not match '^[a-z_]+\\\\.[a-z_]+$'",
5629
"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
6930
}
7031
],
7132
"parse_errors": []

negative_test/roles/meta_invalid_collections/meta/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
version: 2 # <-- role inside a collection
1+
# role inside a collection
22
collections:
33
- FOO.BAR # invalid pattern, need to use lowercase
44
galaxy_info:
5+
standalone: false
56
description: foo
67
license: bar
78
platforms:

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,6 @@
1010
"pattern": "^[a-z_]+\\.[a-z_]+$"
1111
},
1212
"schemaPath": "#/$defs/collections/items/pattern"
13-
},
14-
{
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",
34-
"keyword": "if",
35-
"message": "must match \"then\" schema",
36-
"params": {
37-
"failingKeyword": "then"
38-
},
39-
"schemaPath": "#/if"
4013
}
4114
]
4215
```
@@ -54,18 +27,6 @@ stdout:
5427
"path": "$.collections[0]",
5528
"message": "'FOO.BAR' does not match '^[a-z_]+\\\\.[a-z_]+$'",
5629
"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
6930
}
7031
],
7132
"parse_errors": []

negative_test/roles/meta_invalid_role_namespace/meta/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
version: 1 # <-- old standalone role
2+
# old standalone role
33
galaxy_info:
44
description: foo
55
min_ansible_version: "2.9"

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22

33
```json
44
[
5+
{
6+
"instancePath": "/galaxy_info",
7+
"keyword": "required",
8+
"message": "must have required property 'author'",
9+
"params": {
10+
"missingProperty": "author"
11+
},
12+
"schemaPath": "#/allOf/0/then/required"
13+
},
514
{
615
"instancePath": "/galaxy_info",
716
"keyword": "required",
817
"message": "must have required property 'standalone'",
918
"params": {
1019
"missingProperty": "standalone"
1120
},
12-
"schemaPath": "#/then/required"
21+
"schemaPath": "#/allOf/0/then/required"
1322
},
1423
{
1524
"instancePath": "/galaxy_info",
@@ -18,7 +27,25 @@
1827
"params": {
1928
"failingKeyword": "then"
2029
},
21-
"schemaPath": "#/if"
30+
"schemaPath": "#/allOf/0/if"
31+
},
32+
{
33+
"instancePath": "/galaxy_info",
34+
"keyword": "required",
35+
"message": "must have required property 'standalone'",
36+
"params": {
37+
"missingProperty": "standalone"
38+
},
39+
"schemaPath": "#/allOf/1/then/required"
40+
},
41+
{
42+
"instancePath": "/galaxy_info",
43+
"keyword": "if",
44+
"message": "must match \"then\" schema",
45+
"params": {
46+
"failingKeyword": "then"
47+
},
48+
"schemaPath": "#/allOf/1/if"
2249
},
2350
{
2451
"instancePath": "/galaxy_info/namespace",
@@ -40,6 +67,18 @@ stdout:
4067
{
4168
"status": "fail",
4269
"errors": [
70+
{
71+
"filename": "negative_test/roles/meta_invalid_role_namespace/meta/main.yml",
72+
"path": "$.galaxy_info",
73+
"message": "'author' is a required property",
74+
"has_sub_errors": false
75+
},
76+
{
77+
"filename": "negative_test/roles/meta_invalid_role_namespace/meta/main.yml",
78+
"path": "$.galaxy_info",
79+
"message": "'standalone' is a required property",
80+
"has_sub_errors": false
81+
},
4382
{
4483
"filename": "negative_test/roles/meta_invalid_role_namespace/meta/main.yml",
4584
"path": "$.galaxy_info",

negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 1 # <-- old standalone role
1+
# old standalone role
22
galaxy_info:
33
description: bar
44
min_ansible_version: "2.9"

0 commit comments

Comments
 (0)