mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-30 21:09:09 -07:00
Add AnsibleModule signature schema, and fix associated issues (#43512)
This commit is contained in:
parent
25218e6843
commit
01c0446cb5
16 changed files with 72 additions and 36 deletions
|
@ -16,10 +16,41 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from voluptuous import PREVENT_EXTRA, Any, Required, Schema, Self
|
||||
from voluptuous import PREVENT_EXTRA, All, Any, Length, Required, Schema, Self
|
||||
from ansible.module_utils.six import string_types
|
||||
list_string_types = list(string_types)
|
||||
|
||||
|
||||
def sequence_of_sequences(min=None, max=None):
|
||||
return All(
|
||||
Any(
|
||||
None,
|
||||
[Length(min=min, max=max)],
|
||||
tuple([Length(min=min, max=max)]),
|
||||
),
|
||||
Any(
|
||||
None,
|
||||
[Any(list, tuple)],
|
||||
tuple([Any(list, tuple)]),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
ansible_module_kwargs_schema = Schema(
|
||||
{
|
||||
'argument_spec': dict,
|
||||
'bypass_checks': bool,
|
||||
'no_log': bool,
|
||||
'check_invalid_arguments': Any(None, bool),
|
||||
'mutually_exclusive': sequence_of_sequences(min=2),
|
||||
'required_together': sequence_of_sequences(min=2),
|
||||
'required_one_of': sequence_of_sequences(min=2),
|
||||
'add_file_common_args': bool,
|
||||
'supports_check_mode': bool,
|
||||
'required_if': sequence_of_sequences(min=3),
|
||||
}
|
||||
)
|
||||
|
||||
suboption_schema = Schema(
|
||||
{
|
||||
Required('description'): Any(list_string_types, *string_types),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue