mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 04:40:22 -07:00
cargo: add support for --features flag (#10198)
* feat(cargo): add --features flag to cargo module so it activates through install * docs(cargo): 10198 cargo features parameter changelog * docs: fix wrong pull request number in yml file * docs: match default [] to be the same in docs and specs * docs: bump version_added from 10.8.0 to 11.0.0 * style(example): change from json sequence syntax to yaml list
This commit is contained in:
parent
1956815884
commit
497fcd350f
2 changed files with 21 additions and 0 deletions
2
changelogs/fragments/10198-cargo-features-parameter.yml
Normal file
2
changelogs/fragments/10198-cargo-features-parameter.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- cargo - add ``features`` parameter to allow activating specific features when installing Rust packages (https://github.com/ansible-collections/community.general/pull/10198).
|
|
@ -68,6 +68,15 @@ options:
|
||||||
type: path
|
type: path
|
||||||
required: false
|
required: false
|
||||||
version_added: 9.1.0
|
version_added: 9.1.0
|
||||||
|
features:
|
||||||
|
description:
|
||||||
|
- List of features to activate.
|
||||||
|
- This is only used when installing packages.
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
required: false
|
||||||
|
default: []
|
||||||
|
version_added: 11.0.0
|
||||||
requirements:
|
requirements:
|
||||||
- cargo installed
|
- cargo installed
|
||||||
"""
|
"""
|
||||||
|
@ -106,6 +115,12 @@ EXAMPLES = r"""
|
||||||
community.general.cargo:
|
community.general.cargo:
|
||||||
name: ludusavi
|
name: ludusavi
|
||||||
directory: /path/to/ludusavi/source
|
directory: /path/to/ludusavi/source
|
||||||
|
|
||||||
|
- name: Install "serpl" Rust package with ast_grep feature
|
||||||
|
community.general.cargo:
|
||||||
|
name: serpl
|
||||||
|
features:
|
||||||
|
- ast_grep
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
@ -125,6 +140,7 @@ class Cargo(object):
|
||||||
self.version = kwargs["version"]
|
self.version = kwargs["version"]
|
||||||
self.locked = kwargs["locked"]
|
self.locked = kwargs["locked"]
|
||||||
self.directory = kwargs["directory"]
|
self.directory = kwargs["directory"]
|
||||||
|
self.features = kwargs["features"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path(self):
|
def path(self):
|
||||||
|
@ -176,6 +192,8 @@ class Cargo(object):
|
||||||
if self.directory:
|
if self.directory:
|
||||||
cmd.append("--path")
|
cmd.append("--path")
|
||||||
cmd.append(self.directory)
|
cmd.append(self.directory)
|
||||||
|
if self.features:
|
||||||
|
cmd += ["--features", ",".join(self.features)]
|
||||||
return self._exec(cmd)
|
return self._exec(cmd)
|
||||||
|
|
||||||
def is_outdated(self, name):
|
def is_outdated(self, name):
|
||||||
|
@ -236,6 +254,7 @@ def main():
|
||||||
version=dict(default=None, type="str"),
|
version=dict(default=None, type="str"),
|
||||||
locked=dict(default=False, type="bool"),
|
locked=dict(default=False, type="bool"),
|
||||||
directory=dict(default=None, type="path"),
|
directory=dict(default=None, type="path"),
|
||||||
|
features=dict(default=[], required=False, type="list", elements="str"),
|
||||||
)
|
)
|
||||||
module = AnsibleModule(argument_spec=arg_spec, supports_check_mode=True)
|
module = AnsibleModule(argument_spec=arg_spec, supports_check_mode=True)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue