-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schema: add validation of argument_specs.yml files (#2131)
Fixes: #1966
- Loading branch information
Showing
6 changed files
with
189 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
argument_specs: | ||
main: | ||
foo: bar # <-- invalid based on json schema | ||
options: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
# https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#role-argument-validation | ||
argument_specs: | ||
main: | ||
short_description: The main entry point for the role. | ||
description: "a longer description" | ||
options: | ||
my_app_int: | ||
type: "int" | ||
required: false | ||
default: 42 | ||
description: "The integer value, defaulting to 42." | ||
no_log: false | ||
|
||
my_app_str: | ||
type: "str" | ||
required: true | ||
description: "The string value" | ||
|
||
alternate: | ||
short_description: The alternate entry point for the my_app role. | ||
options: | ||
my_app_int: | ||
type: "int" | ||
required: false | ||
default: 1024 | ||
description: "The integer value, defaulting to 1024." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
{ | ||
"$id": "https://raw.githubusercontent.com/ansible/schemas/main/f/ansible-argument-specs.json", | ||
"$schema": "http://json-schema.org/draft-07/schema", | ||
"additionalProperties": false, | ||
"definitions": { | ||
"datatype": { | ||
"enum": [ | ||
"str", | ||
"list", | ||
"dict", | ||
"bool", | ||
"int", | ||
"float", | ||
"path", | ||
"raw", | ||
"jsonarg", | ||
"json", | ||
"bytes", | ||
"bits" | ||
], | ||
"type": "string" | ||
}, | ||
"deprecated_alias": { | ||
"properties": { | ||
"collection_name": { | ||
"type": "string" | ||
}, | ||
"date": { | ||
"type": "string" | ||
}, | ||
"name": { | ||
"type": "string" | ||
}, | ||
"version": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["name"], | ||
"type": "object" | ||
}, | ||
"entry_point": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"author": { | ||
"type": "string" | ||
}, | ||
"description": { | ||
"type": "string" | ||
}, | ||
"options": { | ||
"additionalProperties": { | ||
"$ref": "#/definitions/option" | ||
}, | ||
"type": "object" | ||
}, | ||
"short_description": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["options"], | ||
"title": "Entry Point", | ||
"type": "object" | ||
}, | ||
"option": { | ||
"additionalProperties": false, | ||
"aliases": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"apply_defaults": { | ||
"type": "string" | ||
}, | ||
"deprecated_aliases": { | ||
"items": { | ||
"$ref": "#/definitions/deprecated_alias" | ||
}, | ||
"type": "array" | ||
}, | ||
"markdownDescription": "xxx", | ||
"options": { | ||
"$ref": "#/definitions/option" | ||
}, | ||
"properties": { | ||
"choices": { | ||
"$ref": "#/definitions/datatype" | ||
}, | ||
"default": { | ||
"default": "None" | ||
}, | ||
"description": { | ||
"description": "Detailed explanation of what this option does. It should be written in full sentences.", | ||
"type": "string" | ||
}, | ||
"elements": { | ||
"$ref": "#/definitions/datatype" | ||
}, | ||
"fallback": { | ||
"default": "None", | ||
"type": "string" | ||
}, | ||
"no_log": { | ||
"default": false, | ||
"type": "boolean" | ||
}, | ||
"option-name": { | ||
"description": "The name of the option/argument.", | ||
"type": "string" | ||
}, | ||
"required": { | ||
"default": false, | ||
"type": "boolean" | ||
}, | ||
"type": { | ||
"$ref": "#/definitions/datatype", | ||
"markdownDescription": "See [argument-spec](https://docs.ansible.com/ansible/latest/dev_guide/developing_program_flow_modules.html#argument-spec" | ||
} | ||
}, | ||
"removed_at_date": { | ||
"type": "string" | ||
}, | ||
"removed_from_collection": { | ||
"type": "string" | ||
}, | ||
"removed_in_version": { | ||
"type": "string" | ||
}, | ||
"title": "Option" | ||
} | ||
}, | ||
"examples": ["meta/argument_specs.yml"], | ||
"markdownDescription": "Add entry point, usually `main`.\nSee [role-argument-validation](https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#role-argument-validation)", | ||
"properties": { | ||
"argument_specs": { | ||
"additionalProperties": { | ||
"$ref": "#/definitions/entry_point" | ||
}, | ||
"markdownDescription": "Add entry point, usually `main`.\nSee [role-argument-validation](https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#role-argument-validation)" | ||
} | ||
}, | ||
"title": "Ansible Argument Specs Schema" | ||
} |