Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible core added a new field, cli for a single plugin. #277

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions antsibull/schemas/base.py
Expand Up @@ -129,6 +129,11 @@ def handle_renamed_attribute(cls, values):
_SENTINEL = object()


#: Constrained string for valid Ansible cli args.
#: Must not start or end with an underscore, must not contain double underscores, lowercase ascii
#: letters, digits, and single underscores are okay.
REQUIRED_CLI_F = p.Field(..., regex='^[a-z0-9]+(_[a-z0-9]+)*$')

#: Constrained string for valid Ansible environment variables
REQUIRED_ENV_VAR_F = p.Field(..., regex='[A-Z_]+')

Expand Down
10 changes: 9 additions & 1 deletion antsibull/schemas/plugin.py
Expand Up @@ -12,14 +12,21 @@

import pydantic as p

from .base import (REQUIRED_ENV_VAR_F, RETURN_TYPE_F,
from .base import (REQUIRED_CLI_F, REQUIRED_ENV_VAR_F, RETURN_TYPE_F,
COLLECTION_NAME_F, BaseModel, DeprecationSchema, DocSchema,
LocalConfig, OptionsSchema, list_from_scalars, is_json_value,
normalize_return_type_names, transform_return_docs)

_SENTINEL = object()


class OptionCliSchema(BaseModel):
name: str = REQUIRED_CLI_F
deprecated: DeprecationSchema = p.Field({})
version_added: str = 'historical'
version_added_collection: str = COLLECTION_NAME_F


class OptionEnvSchema(BaseModel):
name: str = REQUIRED_ENV_VAR_F
deprecated: DeprecationSchema = p.Field({})
Expand Down Expand Up @@ -114,6 +121,7 @@ class OuterReturnSchema(ReturnSchema):


class PluginOptionsSchema(OptionsSchema):
cli: t.List[OptionCliSchema] = []
env: t.List[OptionEnvSchema] = []
ini: t.List[OptionIniSchema] = []
suboptions: t.Dict[str, 'PluginOptionsSchema'] = {}
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_become_results.json
Expand Up @@ -22,6 +22,7 @@
"become_pass": {
"aliases": [],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/schema/good_data/one_cache_results.json
Expand Up @@ -19,6 +19,7 @@
"_prefix": {
"aliases": [],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -52,6 +53,7 @@
"_timeout": {
"aliases": [],
"choices": [],
"cli": [],
"default": 86400,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -85,6 +87,7 @@
"_uri": {
"aliases": [],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_cliconf_results.json
Expand Up @@ -19,6 +19,7 @@
"eos_use_sessions": {
"aliases": [],
"choices": [],
"cli": [],
"default": 1,
"deprecated": {},
"description": [
Expand Down
13 changes: 13 additions & 0 deletions tests/functional/schema/good_data/one_connection_results.json
Expand Up @@ -19,6 +19,7 @@
"become": {
"aliases": [],
"choices": [],
"cli": [],
"default": 0,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -60,6 +61,7 @@
"become_method": {
"aliases": [],
"choices": [],
"cli": [],
"default": "sudo",
"deprecated": {},
"description": [
Expand Down Expand Up @@ -100,6 +102,7 @@
"host": {
"aliases": [],
"choices": [],
"cli": [],
"default": "inventory_hostname",
"deprecated": {},
"description": [
Expand All @@ -125,6 +128,7 @@
"network_os": {
"aliases": [],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand All @@ -150,6 +154,7 @@
"password": {
"aliases": [],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -187,6 +192,7 @@
"persistent_command_timeout": {
"aliases": [],
"choices": [],
"cli": [],
"default": 30,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -227,6 +233,7 @@
"persistent_connect_timeout": {
"aliases": [],
"choices": [],
"cli": [],
"default": 30,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -267,6 +274,7 @@
"persistent_log_messages": {
"aliases": [],
"choices": [],
"cli": [],
"default": 0,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -308,6 +316,7 @@
"port": {
"aliases": [],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -349,6 +358,7 @@
"remote_user": {
"aliases": [],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -390,6 +400,7 @@
"use_proxy": {
"aliases": [],
"choices": [],
"cli": [],
"default": 1,
"deprecated": {},
"description": [
Expand All @@ -415,6 +426,7 @@
"use_ssl": {
"aliases": [],
"choices": [],
"cli": [],
"default": 0,
"deprecated": {},
"description": [
Expand All @@ -440,6 +452,7 @@
"validate_certs": {
"aliases": [],
"choices": [],
"cli": [],
"default": 1,
"deprecated": {},
"description": [
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_httpapi_results.json
Expand Up @@ -19,6 +19,7 @@
"root_path": {
"aliases": [],
"choices": [],
"cli": [],
"default": "/restconf",
"deprecated": {},
"description": [
Expand Down
21 changes: 21 additions & 0 deletions tests/functional/schema/good_data/one_inventory_results.json
Expand Up @@ -24,6 +24,7 @@
"aws_access_key_id"
],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -63,6 +64,7 @@
"boto_profile"
],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -96,6 +98,7 @@
"aws_secret_access_key"
],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -133,6 +136,7 @@
"aws_security_token": {
"aliases": [],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -170,6 +174,7 @@
"cache": {
"aliases": [],
"choices": [],
"cli": [],
"default": 0,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -203,6 +208,7 @@
"cache_connection": {
"aliases": [],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -249,6 +255,7 @@
"cache_plugin": {
"aliases": [],
"choices": [],
"cli": [],
"default": "memory",
"deprecated": {},
"description": [
Expand Down Expand Up @@ -295,6 +302,7 @@
"cache_prefix": {
"aliases": [],
"choices": [],
"cli": [],
"default": "ansible_inventory_",
"deprecated": {},
"description": [
Expand Down Expand Up @@ -341,6 +349,7 @@
"cache_timeout": {
"aliases": [],
"choices": [],
"cli": [],
"default": 3600,
"deprecated": {},
"description": [
Expand Down Expand Up @@ -387,6 +396,7 @@
"compose": {
"aliases": [],
"choices": [],
"cli": [],
"default": {},
"deprecated": {},
"description": [
Expand All @@ -405,6 +415,7 @@
"filters": {
"aliases": [],
"choices": [],
"cli": [],
"default": {},
"deprecated": {},
"description": [
Expand All @@ -424,6 +435,7 @@
"groups": {
"aliases": [],
"choices": [],
"cli": [],
"default": {},
"deprecated": {},
"description": [
Expand All @@ -442,6 +454,7 @@
"hostnames": {
"aliases": [],
"choices": [],
"cli": [],
"default": [],
"deprecated": {},
"description": [
Expand All @@ -462,6 +475,7 @@
"iam_role_arn": {
"aliases": [],
"choices": [],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand All @@ -480,6 +494,7 @@
"include_extra_api_calls": {
"aliases": [],
"choices": [],
"cli": [],
"default": 0,
"deprecated": {},
"description": [
Expand All @@ -499,6 +514,7 @@
"keyed_groups": {
"aliases": [],
"choices": [],
"cli": [],
"default": [],
"deprecated": {},
"description": [
Expand All @@ -519,6 +535,7 @@
"choices": [
"aws_ec2"
],
"cli": [],
"default": null,
"deprecated": {},
"description": [
Expand All @@ -537,6 +554,7 @@
"regions": {
"aliases": [],
"choices": [],
"cli": [],
"default": [],
"deprecated": {},
"description": [
Expand All @@ -556,6 +574,7 @@
"strict": {
"aliases": [],
"choices": [],
"cli": [],
"default": 0,
"deprecated": {},
"description": [
Expand All @@ -575,6 +594,7 @@
"strict_permissions": {
"aliases": [],
"choices": [],
"cli": [],
"default": 1,
"deprecated": {},
"description": [
Expand All @@ -594,6 +614,7 @@
"use_contrib_script_compatible_sanitization": {
"aliases": [],
"choices": [],
"cli": [],
"default": 0,
"deprecated": {},
"description": [
Expand Down