diff --git a/f/ansible-meta.json b/f/ansible-meta.json index 346130ef..116ff3ef 100644 --- a/f/ansible-meta.json +++ b/f/ansible-meta.json @@ -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", @@ -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": { diff --git a/negative_test/roles/meta/main.yml b/negative_test/roles/meta/main.yml index 6ca7dfe9..3ed9a8c2 100644 --- a/negative_test/roles/meta/main.yml +++ b/negative_test/roles/meta/main.yml @@ -1,4 +1,3 @@ -version: 1 galaxy_info: description: bar min_ansible_version: "2.9" diff --git a/negative_test/roles/meta/main.yml.md b/negative_test/roles/meta/main.yml.md index 935f30c6..eab7332b 100644 --- a/negative_test/roles/meta/main.yml.md +++ b/negative_test/roles/meta/main.yml.md @@ -2,6 +2,15 @@ ```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", @@ -9,7 +18,7 @@ "params": { "missingProperty": "standalone" }, - "schemaPath": "#/then/required" + "schemaPath": "#/allOf/0/then/required" }, { "instancePath": "/galaxy_info", @@ -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", @@ -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", diff --git a/negative_test/roles/meta_invalid_collection/meta/main.yml b/negative_test/roles/meta_invalid_collection/meta/main.yml index 56cac591..1fa41ebe 100644 --- a/negative_test/roles/meta_invalid_collection/meta/main.yml +++ b/negative_test/roles/meta_invalid_collection/meta/main.yml @@ -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: diff --git a/negative_test/roles/meta_invalid_collection/meta/main.yml.md b/negative_test/roles/meta_invalid_collection/meta/main.yml.md index 0a7e9acb..1b8dcd0e 100644 --- a/negative_test/roles/meta_invalid_collection/meta/main.yml.md +++ b/negative_test/roles/meta_invalid_collection/meta/main.yml.md @@ -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" } ] ``` @@ -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": [] diff --git a/negative_test/roles/meta_invalid_collections/meta/main.yml b/negative_test/roles/meta_invalid_collections/meta/main.yml index d3b84fc9..488928cf 100644 --- a/negative_test/roles/meta_invalid_collections/meta/main.yml +++ b/negative_test/roles/meta_invalid_collections/meta/main.yml @@ -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: diff --git a/negative_test/roles/meta_invalid_collections/meta/main.yml.md b/negative_test/roles/meta_invalid_collections/meta/main.yml.md index 0555ed91..5d775f02 100644 --- a/negative_test/roles/meta_invalid_collections/meta/main.yml.md +++ b/negative_test/roles/meta_invalid_collections/meta/main.yml.md @@ -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" } ] ``` @@ -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": [] diff --git a/negative_test/roles/meta_invalid_role_namespace/meta/main.yml b/negative_test/roles/meta_invalid_role_namespace/meta/main.yml index 078bba5d..e50e5b7b 100644 --- a/negative_test/roles/meta_invalid_role_namespace/meta/main.yml +++ b/negative_test/roles/meta_invalid_role_namespace/meta/main.yml @@ -1,5 +1,5 @@ --- -version: 1 # <-- old standalone role +# old standalone role galaxy_info: description: foo min_ansible_version: "2.9" diff --git a/negative_test/roles/meta_invalid_role_namespace/meta/main.yml.md b/negative_test/roles/meta_invalid_role_namespace/meta/main.yml.md index 650d7d2b..d4524783 100644 --- a/negative_test/roles/meta_invalid_role_namespace/meta/main.yml.md +++ b/negative_test/roles/meta_invalid_role_namespace/meta/main.yml.md @@ -2,6 +2,15 @@ ```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", @@ -9,7 +18,7 @@ "params": { "missingProperty": "standalone" }, - "schemaPath": "#/then/required" + "schemaPath": "#/allOf/0/then/required" }, { "instancePath": "/galaxy_info", @@ -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", @@ -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", diff --git a/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml b/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml index c871542f..81d4d3db 100644 --- a/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml +++ b/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml @@ -1,4 +1,4 @@ -version: 1 # <-- old standalone role +# old standalone role galaxy_info: description: bar min_ansible_version: "2.9" diff --git a/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml.md b/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml.md index 7158b4f7..3c926a46 100644 --- a/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml.md +++ b/negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml.md @@ -36,6 +36,15 @@ "params": {}, "schemaPath": "#/anyOf" }, + { + "instancePath": "/galaxy_info", + "keyword": "required", + "message": "must have required property 'author'", + "params": { + "missingProperty": "author" + }, + "schemaPath": "#/allOf/0/then/required" + }, { "instancePath": "/galaxy_info", "keyword": "required", @@ -43,7 +52,7 @@ "params": { "missingProperty": "standalone" }, - "schemaPath": "#/then/required" + "schemaPath": "#/allOf/0/then/required" }, { "instancePath": "/galaxy_info", @@ -52,7 +61,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" } ] ``` @@ -89,6 +116,18 @@ stdout: } ] }, + { + "filename": "negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml", + "path": "$.galaxy_info", + "message": "'author' is a required property", + "has_sub_errors": false + }, + { + "filename": "negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml", + "path": "$.galaxy_info", + "message": "'standalone' is a required property", + "has_sub_errors": false + }, { "filename": "negative_test/roles/role_with_bad_deps_in_meta/meta/main.yml", "path": "$.galaxy_info", diff --git a/test/roles/foo/meta/main.yml b/test/roles/foo/meta/main.yml index 1daeac05..6bca2e4d 100644 --- a/test/roles/foo/meta/main.yml +++ b/test/roles/foo/meta/main.yml @@ -34,11 +34,12 @@ dependencies: name: http-role galaxy_info: - standalone: true - description: foo - min_ansible_version: "2.9" + author: John Doe company: foo + description: foo license: MIT + min_ansible_version: "2.9" + standalone: true platforms: - name: Alpine versions: diff --git a/test/roles/maximum/meta/main.yml b/test/roles/maximum/meta/main.yml index cb8219ed..10c57b11 100644 --- a/test/roles/maximum/meta/main.yml +++ b/test/roles/maximum/meta/main.yml @@ -1,5 +1,6 @@ allow_duplicates: true galaxy_info: + author: John Doe standalone: true # v1 role meta (standalone) description: maximum min_ansible_version: "2.9" diff --git a/test/roles/meta-tags/meta/main.yml b/test/roles/meta-tags/meta/main.yml index 3e554e54..3002e420 100644 --- a/test/roles/meta-tags/meta/main.yml +++ b/test/roles/meta-tags/meta/main.yml @@ -17,6 +17,7 @@ dependencies: vars: "foo": bar galaxy_info: + author: John Doe standalone: true description: foo license: MIT diff --git a/test/roles/ns/meta/main.yml b/test/roles/ns/meta/main.yml index 071dec8d..0ea558cf 100644 --- a/test/roles/ns/meta/main.yml +++ b/test/roles/ns/meta/main.yml @@ -1,6 +1,6 @@ --- -version: 1 # v1 role meta (standalone) galaxy_info: + author: John Doe standalone: true description: foo min_ansible_version: "2.9" diff --git a/test/roles/v1_role/meta/main.yml b/test/roles/v1_role/meta/main.yml index 76d907d7..a74eb47d 100644 --- a/test/roles/v1_role/meta/main.yml +++ b/test/roles/v1_role/meta/main.yml @@ -1,5 +1,4 @@ --- -version: 1 # v1 role meta (standalone) galaxy_info: standalone: true author: foo-bar # <-- that is a valid author name because is a valid github username