mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
npm: improve parameter validation (#10983)
* npm: improve parameter validation * add changelog frag * add required_if clause * fix required_if, add required_one_of, add docs * Update plugins/modules/npm.py * Update plugins/modules/npm.py * Update plugins/modules/npm.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/npm.py Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
54af64ad36
commit
7e8e8948a3
2 changed files with 8 additions and 4 deletions
2
changelogs/fragments/10983-npm-param-mutex.yml
Normal file
2
changelogs/fragments/10983-npm-param-mutex.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- npm - improve parameter validation using Ansible construct (https://github.com/ansible-collections/community.general/pull/10983).
|
||||
|
|
@ -28,6 +28,7 @@ options:
|
|||
path:
|
||||
description:
|
||||
- The base path where to install the node.js libraries.
|
||||
- When O(global=true), then O(path) is not used to install the packages.
|
||||
type: path
|
||||
required: false
|
||||
version:
|
||||
|
|
@ -38,6 +39,7 @@ options:
|
|||
global:
|
||||
description:
|
||||
- Install the node.js library globally.
|
||||
- When O(global=true), then O(path) is not used to install the packages.
|
||||
required: false
|
||||
default: false
|
||||
type: bool
|
||||
|
|
@ -303,7 +305,10 @@ def main():
|
|||
arg_spec['global'] = dict(default=False, type='bool')
|
||||
module = AnsibleModule(
|
||||
argument_spec=arg_spec,
|
||||
required_if=[('state', 'absent', ['name'])],
|
||||
required_if=[
|
||||
('state', 'absent', ['name']),
|
||||
("global", False, ["path"]),
|
||||
],
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
|
|
@ -313,9 +318,6 @@ def main():
|
|||
glbl = module.params['global']
|
||||
state = module.params['state']
|
||||
|
||||
if not path and not glbl:
|
||||
module.fail_json(msg='path must be specified when not using global')
|
||||
|
||||
npm = Npm(module,
|
||||
name=name,
|
||||
path=path,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue