Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
make dumping galaxy platforms configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Ziegenberg <[email protected]>
  • Loading branch information
ziegenberg committed Dec 17, 2021
1 parent a1908ab commit c8a4730
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/ansibleschemas/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import multiprocessing
import os
import subprocess
from argparse import ArgumentParser, Namespace, RawTextHelpFormatter
from pathlib import Path
from typing import Dict, List

Expand All @@ -28,6 +29,34 @@
module_dir = Path(__file__).resolve().parents[0]


def parse_args() -> Namespace:
"""Parse commandline arguments."""

example_text = """
examples:
generate schemas without fetching any external data:
ansibleschemas
update the list of Galaxy platforms and generate schemas:
ansibleschemas --dump-galaxy-platforms
"""

parser = ArgumentParser(
description="Generate JSON/YAML Validation schemas for Ansible content.",
prog="ansibleschemas",
epilog=example_text,
formatter_class=RawTextHelpFormatter,
)
parser.add_argument(
'-p',
'--dump-galaxy-platforms',
default=os.environ.get('DUMP_GALAXY_PLATFORMS'),
action='store_true',
help="Query the Galaxy API and dump all Galaxy platforms into a python module.",
)
return parser.parse_args()


def pretty_plattforms(value: dict) -> str:
"""Pretty prints the plattform dictionary"""
items = [
Expand Down Expand Up @@ -145,7 +174,10 @@ def map_type(ansible_type: str) -> str:
def main() -> None:
"""Main entry point"""

dump_galaxy_platforms()
args = parse_args()

if args.dump_galaxy_platforms:
dump_galaxy_platforms()

schemas = {
"ansible-lint": AnsibleLintModel,
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ passenv =
PY_COLORS
REQUESTS_CA_BUNDLE # https proxies
SSL_CERT_FILE # https proxies
DUMP_GALAXY_PLATFORMS
# recreate = True
setenv =
PIP_DISABLE_PIP_VERSION_CHECK = 1
Expand Down

0 comments on commit c8a4730

Please sign in to comment.