Skip to content

Commit

Permalink
common: cleanup unused get_targets function
Browse files Browse the repository at this point in the history
Duplicate wasn't used.

Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed May 5, 2024
1 parent c0104cd commit ea2d060
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions asu/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
from . import __version__


def get_branch(version):
def get_branch(version: str) -> str:
"""Return branch of a version
Args:
version (str): Version string
Returns:
str: Branch name
"""
if version.endswith("-SNAPSHOT"):
# e.g. 21.02-snapshot
return version.rsplit("-", maxsplit=1)[0]
Expand Down Expand Up @@ -346,40 +354,30 @@ def check_manifest(manifest, packages_versions):
)


def get_targets_upstream(config: dict, version: str) -> list:
"""Return list of targets for a specific version
def update_targets(config: dict, version):
"""Update available targets of a specific version
Args:
config (dict): Configuration
version (str): Version within branch
Returns:
list: List of targets
version(str): Version within branch
"""
branch = config["BRANCHES"][get_branch(version)]
version_path = branch["path"].format(version=version)
version_path = branch["path"].format(version=branch["versions"][0])

req = requests.get(config["UPSTREAM_URL"] + f"/{version_path}/.targets.json")
targets = requests.get(config["UPSTREAM_URL"] + f"/{version_path}/.targets.json")

return list(req.json().keys())
if targets.status_code != 200:
logging.warning("Couldn't download %s", targets.url)
return


def update_targets(config: dict, version) -> list:
branch = config["BRANCHES"][get_branch(version)]
version_path = branch["path"].format(version=branch["versions"][0])

targets = requests.get(
config["UPSTREAM_URL"] + f"/{version_path}/.targets.json"
).json()
targets = targets.json()

logging.info(f"{branch['name']}: Found {len(targets)} targets")
pipeline = get_redis_client(config).pipeline(True)
pipeline.delete(f"targets:{branch['name']}")
pipeline.hset(f"targets:{branch['name']}", mapping=targets)
pipeline.execute()

return targets


def update_profiles(config, version: str, target: str) -> str:
"""Update available profiles of a specific version
Expand Down

0 comments on commit ea2d060

Please sign in to comment.