module

Krikri::PluginHelpers::AnsibleArgValidation

AnsibleArgValidation - reusable fragments of real AnsibleModule's argument-validation surface (ansible-core's parameters.py / validation.py / arg_spec.py wordings), for the plugins that hand-roll their own argument-spec checks the way the real module's AnsibleModule setup does. Each plugin owns its own merged-spec ORDER (real iterates the merged argument_spec in declaration order and only ever surfaces errors[0]); this module only owns the per-check wording so the copies can't drift apart.

Constants

BOOLEANS_REPR = ["y", "yes", "on", "'1'", "'true'", "'t'", "1", "1.0", "True", "n", "no", "off", "'0'", "'false'", "'f'", "0", "0.0", "False"] of ::String

convert_bool.py's BOOLEANS, repr'd - real Ansible iterates a Python SET here, so the order differs between module processes (PYTHONHASHSEED); this fixed order is one of the orders real emits, and only the wording shape is deterministic.

REAL_FALSE = ["n", "no", "off", "0", "false", "f"] of ::String
REAL_TRUE = ["y", "yes", "on", "1", "true", "t"] of ::String

convert_bool.py's BOOLEANS_TRUE / BOOLEANS_FALSE (the string members; int/bool members can't reach a plugin - wire values are always strings). boolean() lowercases and strips first.

RELATIVE_TIME_RE = /^[+-](\d+[wW])?(\d+[dD])?(\d+[hH])?(\d+[mM])?(\d+[sS]?)?$/

community.crypto's _time.py get_relative_time_option: a timespec is either sshd_config(5)-relative (a leading +/-, then weeks/days/hours/minutes/seconds components in that exact order) or one of four absolute ASN.1/generalized-time shapes. Anything else fails the module with 'The time spec "..." for ... is invalid'.

Instance methods

bool_convertible?(raw : String) : Bool
Source
bool_type_error(param : String, raw : String) : PluginResult
Source
choices_error(param : String, allowed : Array(String), value : String) : PluginResult
Source
crypto_time_spec_valid?(value : String) : Bool
Source
int_type_error(param : String, raw : String) : PluginResult
Source
missing_required_error(missing : Array(String)) : PluginResult
Source
parse_sub_list(raw : String) : Array(JSON::Any)

check_type_list semantics (ansible-core 2.14: a plain string is comma-split, no JSON probing). The wire JSON round-trip is undone first, since every krikri param arrives as a string.

Source
required_together_error(group : Array(String)) : PluginResult
Source
unsupported_param_keys(params : Hash(String, String), spec : Hash(String, Array(String)), sub_spec_keys : Hash(String, Array(String)) = {} of String => Array(String)) : Array(String)

Real _get_unsupported_parameters: any param key outside the spec names and their aliases. Engine-internal executor keys never reach the real module's params - real strips the ansible* internal-args namespace generically before argspec validation (check_mode/diff_mode ride in there), while a user-supplied check_mode is NOT in that namespace and fails validation like any other unsupported param.

Source
unsupported_params_error(module_name : String, unsupported : Array(String), spec : Hash(String, Array(String))) : PluginResult

Real UnsupportedError tail - the live-verified format (bookworm ansible-core 2.14's basic.py, observed via the podman-diff docker_login/docker_network/docker_network_info cases): spec keys sorted, then ONE trailing parenthetical holding ALL the spec's aliases, sorted together, attached to the last name.

Source