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

update and not overwrite the existing list of galaxy platforms #116

Merged
merged 3 commits into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/ansibleschemas/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import subprocess
from argparse import ArgumentParser, Namespace, RawTextHelpFormatter
from pathlib import Path
from typing import Dict, List

import requests

from ansibleschemas._galaxy import GALAXY_PLATFORMS
from ansibleschemas.ansiblelint import AnsibleLintModel
from ansibleschemas.galaxy import GalaxyFileModel
from ansibleschemas.meta import MetaModel
Expand All @@ -24,6 +24,10 @@
out_dir = Path(os.getcwd()) / "f"
module_dir = Path(__file__).resolve().parents[0]

GALAXY_FILE_HEADER = """from typing import Dict, List

GALAXY_PLATFORMS: Dict[str, List[str]]"""


def parse_args() -> Namespace:
"""Parse commandline arguments."""
Expand Down Expand Up @@ -83,7 +87,6 @@ def dump_galaxy_platforms() -> None:
"""Dumps galaxy platforms into a python module."""
filename = f"{module_dir}/_galaxy.py"
print(f"Dumping list of Galaxy platforms to {filename}")
platforms: Dict[str, List[str]] = {}
result = {'next_link': '/api/v1/platforms/'}
while result.get('next_link', None):
url = GALAXY_API_URL + result['next_link']
Expand All @@ -95,13 +98,17 @@ def dump_galaxy_platforms() -> None:
release = entry.get('release', None)
if not name or not isinstance(name, str):
continue
if name and name not in platforms:
platforms[name] = []
if release not in ['any', 'None'] and release not in platforms[name]:
platforms[name].append(release)
if name and name not in GALAXY_PLATFORMS:
GALAXY_PLATFORMS[name] = []
if (
release not in ['any', 'all', 'None']
and release not in GALAXY_PLATFORMS[name]
):
GALAXY_PLATFORMS[name].append(release)
GALAXY_PLATFORMS[name].sort()

with open(filename, "w") as file:
file.write(f"GALAXY_PLATFORMS = {pretty_plattforms(platforms)}\n")
file.write(f"{GALAXY_FILE_HEADER} = {pretty_plattforms(GALAXY_PLATFORMS)}\n")


def dump_module_doc(module):
Expand Down
4 changes: 3 additions & 1 deletion src/ansibleschemas/_galaxy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
GALAXY_PLATFORMS = {
from typing import Dict, List

GALAXY_PLATFORMS: Dict[str, List[str]] = {
'AIX': ['6.1', '7.1', '7.2'],
'Alpine': [],
'Amazon': [
Expand Down