Skip to content

Commit

Permalink
Refactor to implement a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolenz committed Jan 10, 2024
1 parent 0b08af0 commit e88601b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
14 changes: 4 additions & 10 deletions plugins/action/generate_cloud_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
)
# import for amazon.cloud doc generation
from ansible_collections.ansible.content_builder.plugins.plugin_utils.cloud_utils.generator import generate_documentation
# import for vmware.vware_rest runtime.yml generation
from ansible_collections.ansible.content_builder.plugins.plugin_utils.cloud_utils.generator import generate_runtime_yml


# vmware specific
Expand Down Expand Up @@ -1326,20 +1328,12 @@ def generate_vmware_rest(args: Iterable, role_path: str):
)
module_list.append(module.name)

runtime_yml = generate_runtime_yml(args.get("requires_ansible"), module_list)
meta_dir = pathlib.Path(args.get("target_dir") + "/meta")
meta_dir.mkdir(parents=True, exist_ok=True)

yaml_dict = {
"requires_ansible": (">=%s") % args.get("requires_ansible"),
"action_groups": {"vmware_rest": []},
}

for m in module_list:
yaml_dict["action_groups"]["vmware_rest"].append(m)

runtime_file = meta_dir / "runtime.yml"
with open(runtime_file, "w") as file:
yaml.safe_dump(yaml_dict, file, sort_keys=False)
yaml.safe_dump(runtime_yml, file, sort_keys=False)

return

Expand Down
14 changes: 13 additions & 1 deletion plugins/plugin_utils/cloud_utils/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,18 @@ def preprocess(self) -> Iterable:
return sanitized_options


def generate_runtime_yml(requires_ansible, module_list):
yaml_dict = {
"requires_ansible": (">=%s") % requires_ansible,
"action_groups": {"vmware_rest": []},
}

for m in module_list:
yaml_dict["action_groups"]["vmware_rest"].append(m)

return yaml_dict


def generate_documentation(
module: object, added_ins: Dict, next_version: str, target_dir: str
) -> Iterable:
Expand Down Expand Up @@ -399,4 +411,4 @@ def generate_docs(self, type_name: str):
# TODO: include version
response = self.client.describe_type(Type="RESOURCE", TypeName=type_name)

return response.get("Schema")
return response.get("Schema")

0 comments on commit e88601b

Please sign in to comment.