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

Commit

Permalink
meta: make the standalone field optional (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Sep 18, 2022
1 parent 68da105 commit 069dcca
Show file tree
Hide file tree
Showing 16 changed files with 180 additions and 112 deletions.
63 changes: 45 additions & 18 deletions f/ansible-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,54 @@
},
"GalaxyInfoModel": {
"additionalProperties": false,
"allOf": [
{
"if": {
"properties": {
"standalone": {
"const": true
}
}
},
"then": {
"$comment": "Standalone role, so we require several fields.",
"required": [
"author",
"standalone",
"description",
"license",
"min_ansible_version"
]
}
},
{
"if": {
"properties": {
"standalone": {
"const": false
}
}
},
"then": {
"$comment": "Collection roles do not use most galaxy fields.",
"not": {
"required": [
"cloud_platforms",
"galaxy_tags",
"min_ansible_version",
"namespace",
"platforms",
"role_name"
]
},
"required": ["standalone", "description"]
}
}
],
"else": {
"$comment": "If standalone is false, then we have a collection role and only description is required",
"required": ["description"]
},
"if": {
"properties": {
"standalone": {
"const": true
}
}
},
"properties": {
"author": {
"title": "Author",
Expand Down Expand Up @@ -472,17 +509,7 @@
"type": "boolean"
}
},
"then": {
"$comment": "Standalone role, so we require several fields.",
"required": [
"standalone",
"description",
"license",
"min_ansible_version",
"platforms"
]
},
"title": "GalaxyInfoModel for old standalone role (v1)",
"title": "GalaxyInfoModel",
"type": "object"
},
"GalaxyInfoModel-v2": {
Expand Down
1 change: 0 additions & 1 deletion negative_test/roles/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: 1
galaxy_info:
description: bar
min_ansible_version: "2.9"
Expand Down
43 changes: 41 additions & 2 deletions negative_test/roles/meta/main.yml.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@

```json
[
{
"instancePath": "/galaxy_info",
"keyword": "required",
"message": "must have required property 'author'",
"params": {
"missingProperty": "author"
},
"schemaPath": "#/allOf/0/then/required"
},
{
"instancePath": "/galaxy_info",
"keyword": "required",
"message": "must have required property 'standalone'",
"params": {
"missingProperty": "standalone"
},
"schemaPath": "#/then/required"
"schemaPath": "#/allOf/0/then/required"
},
{
"instancePath": "/galaxy_info",
Expand All @@ -18,7 +27,25 @@
"params": {
"failingKeyword": "then"
},
"schemaPath": "#/if"
"schemaPath": "#/allOf/0/if"
},
{
"instancePath": "/galaxy_info",
"keyword": "required",
"message": "must have required property 'standalone'",
"params": {
"missingProperty": "standalone"
},
"schemaPath": "#/allOf/1/then/required"
},
{
"instancePath": "/galaxy_info",
"keyword": "if",
"message": "must match \"then\" schema",
"params": {
"failingKeyword": "then"
},
"schemaPath": "#/allOf/1/if"
},
{
"instancePath": "/galaxy_info/galaxy_tags",
Expand All @@ -40,6 +67,18 @@ stdout:
{
"status": "fail",
"errors": [
{
"filename": "negative_test/roles/meta/main.yml",
"path": "$.galaxy_info",
"message": "'author' is a required property",
"has_sub_errors": false
},
{
"filename": "negative_test/roles/meta/main.yml",
"path": "$.galaxy_info",
"message": "'standalone' is a required property",
"has_sub_errors": false
},
{
"filename": "negative_test/roles/meta/main.yml",
"path": "$.galaxy_info",
Expand Down
2 changes: 1 addition & 1 deletion negative_test/roles/meta_invalid_collection/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2 # <-- role inside a collection
collections:
- foo # invalid pattern
galaxy_info:
standalone: false # role inside a collection
description: foo
license: bar
platforms:
Expand Down
39 changes: 0 additions & 39 deletions negative_test/roles/meta_invalid_collection/meta/main.yml.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,6 @@
"pattern": "^[a-z_]+\\.[a-z_]+$"
},
"schemaPath": "#/$defs/collections/items/pattern"
},
{
"instancePath": "/galaxy_info",
"keyword": "required",
"message": "must have required property 'standalone'",
"params": {
"missingProperty": "standalone"
},
"schemaPath": "#/then/required"
},
{
"instancePath": "/galaxy_info",
"keyword": "required",
"message": "must have required property 'min_ansible_version'",
"params": {
"missingProperty": "min_ansible_version"
},
"schemaPath": "#/then/required"
},
{
"instancePath": "/galaxy_info",
"keyword": "if",
"message": "must match \"then\" schema",
"params": {
"failingKeyword": "then"
},
"schemaPath": "#/if"
}
]
```
Expand All @@ -54,18 +27,6 @@ stdout:
"path": "$.collections[0]",
"message": "'foo' does not match '^[a-z_]+\\\\.[a-z_]+$'",
"has_sub_errors": false
},
{
"filename": "negative_test/roles/meta_invalid_collection/meta/main.yml",
"path": "$.galaxy_info",
"message": "'standalone' is a required property",
"has_sub_errors": false
},
{
"filename": "negative_test/roles/meta_invalid_collection/meta/main.yml",
"path": "$.galaxy_info",
"message": "'min_ansible_version' is a required property",
"has_sub_errors": false
}
],
"parse_errors": []
Expand Down
3 changes: 2 additions & 1 deletion negative_test/roles/meta_invalid_collections/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
version: 2 # <-- role inside a collection
# role inside a collection
collections:
- FOO.BAR # invalid pattern, need to use lowercase
galaxy_info:
standalone: false
description: foo
license: bar
platforms:
Expand Down
39 changes: 0 additions & 39 deletions negative_test/roles/meta_invalid_collections/meta/main.yml.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,6 @@
"pattern": "^[a-z_]+\\.[a-z_]+$"
},
"schemaPath": "#/$defs/collections/items/pattern"
},
{
"instancePath": "/galaxy_info",
"keyword": "required",
"message": "must have required property 'standalone'",
"params": {
"missingProperty": "standalone"
},
"schemaPath": "#/then/required"
},
{
"instancePath": "/galaxy_info",
"keyword": "required",
"message": "must have required property 'min_ansible_version'",
"params": {
"missingProperty": "min_ansible_version"
},
"schemaPath": "#/then/required"
},
{
"instancePath": "/galaxy_info",
"keyword": "if",
"message": "must match \"then\" schema",
"params": {
"failingKeyword": "then"
},
"schemaPath": "#/if"
}
]
```
Expand All @@ -54,18 +27,6 @@ stdout:
"path": "$.collections[0]",
"message": "'FOO.BAR' does not match '^[a-z_]+\\\\.[a-z_]+$'",
"has_sub_errors": false
},
{
"filename": "negative_test/roles/meta_invalid_collections/meta/main.yml",
"path": "$.galaxy_info",
"message": "'standalone' is a required property",
"has_sub_errors": false
},
{
"filename": "negative_test/roles/meta_invalid_collections/meta/main.yml",
"path": "$.galaxy_info",
"message": "'min_ansible_version' is a required property",
"has_sub_errors": false
}
],
"parse_errors": []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
version: 1 # <-- old standalone role
# old standalone role
galaxy_info:
description: foo
min_ansible_version: "2.9"
Expand Down
43 changes: 41 additions & 2 deletions negative_test/roles/meta_invalid_role_namespace/meta/main.yml.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@

```json
[
{
"instancePath": "/galaxy_info",
"keyword": "required",
"message": "must have required property 'author'",
"params": {
"missingProperty": "author"
},
"schemaPath": "#/allOf/0/then/required"
},
{
"instancePath": "/galaxy_info",
"keyword": "required",
"message": "must have required property 'standalone'",
"params": {
"missingProperty": "standalone"
},
"schemaPath": "#/then/required"
"schemaPath": "#/allOf/0/then/required"
},
{
"instancePath": "/galaxy_info",
Expand All @@ -18,7 +27,25 @@
"params": {
"failingKeyword": "then"
},
"schemaPath": "#/if"
"schemaPath": "#/allOf/0/if"
},
{
"instancePath": "/galaxy_info",
"keyword": "required",
"message": "must have required property 'standalone'",
"params": {
"missingProperty": "standalone"
},
"schemaPath": "#/allOf/1/then/required"
},
{
"instancePath": "/galaxy_info",
"keyword": "if",
"message": "must match \"then\" schema",
"params": {
"failingKeyword": "then"
},
"schemaPath": "#/allOf/1/if"
},
{
"instancePath": "/galaxy_info/namespace",
Expand All @@ -40,6 +67,18 @@ stdout:
{
"status": "fail",
"errors": [
{
"filename": "negative_test/roles/meta_invalid_role_namespace/meta/main.yml",
"path": "$.galaxy_info",
"message": "'author' is a required property",
"has_sub_errors": false
},
{
"filename": "negative_test/roles/meta_invalid_role_namespace/meta/main.yml",
"path": "$.galaxy_info",
"message": "'standalone' is a required property",
"has_sub_errors": false
},
{
"filename": "negative_test/roles/meta_invalid_role_namespace/meta/main.yml",
"path": "$.galaxy_info",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1 # <-- old standalone role
# old standalone role
galaxy_info:
description: bar
min_ansible_version: "2.9"
Expand Down
Loading

0 comments on commit 069dcca

Please sign in to comment.