Skip to content

Commit

Permalink
schema: detect invalid space in meta runtime (#2873)
Browse files Browse the repository at this point in the history
Co-authored-by: Ajinkya Udgirkar <ajinkyaudgirkar@gmail.com>
  • Loading branch information
ssbarnea and audgirka committed Jan 10, 2023
1 parent fb6a3eb commit d3b2bae
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/playbooks/collections/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ collections:
version: 0.1.0
- name: ansible-posix-1.4.0.tar.gz
version: 1.4.0
- name: community-general-6.1.0.tar.gz
version: 6.1.0
- name: community-general-6.2.0.tar.gz
version: 6.2.0
1 change: 1 addition & 0 deletions src/ansiblelint/schemas/meta-runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
},
"requires_ansible": {
"examples": [">=2.10,<2.11"],
"pattern": "^[^\\s]*$",
"title": "The version of Ansible Core (ansible-core) required to use the collection. Multiple versions can be separated with a comma.",
"type": "string"
}
Expand Down
1 change: 1 addition & 0 deletions test/schemas/negative_test/meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requires_ansible: ">= 2.12" # invalid as space is not allowed!
34 changes: 34 additions & 0 deletions test/schemas/negative_test/meta/runtime.yml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ajv errors

```json
[
{
"instancePath": "/requires_ansible",
"keyword": "pattern",
"message": "must match pattern \"^[^\\s]*$\"",
"params": {
"pattern": "^[^\\s]*$"
},
"schemaPath": "#/properties/requires_ansible/pattern"
}
]
```

# check-jsonschema

stdout:

```json
{
"status": "fail",
"errors": [
{
"filename": "negative_test/meta/runtime.yml",
"path": "$.requires_ansible",
"message": "'>= 2.12' does not match '^[^\\\\s]*$'",
"has_sub_errors": false
}
],
"parse_errors": []
}
```

0 comments on commit d3b2bae

Please sign in to comment.