Skip to content

Commit

Permalink
fix precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
Akm0d committed Nov 1, 2024
1 parent a379dd8 commit d2c23de
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions salt/utils/relenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ def get_tarball(base_url, kernel, arch):
latest_tarball = matches[-1]
return base_url + latest_tarball


def get_latest_version(base_url):
try:
response = requests.get(base_url, timeout=60)
response.raise_for_status()
except requests.RequestException as e:
log.error(f"Failed to retrieve directory listing: {e}")
raise ValueError("Unable to fetch directory list from repository")

# Extract version numbers from hrefs
pattern = re.compile(r'href="(\d+\.\d+)/"')
versions = pattern.findall(response.text)
Expand All @@ -93,9 +94,10 @@ def get_latest_version(base_url):
raise ValueError("No versions found in directory listing")

# Sort versions numerically and return the latest one
versions.sort(key=lambda s: list(map(int, s.split('.'))), reverse=True)
versions.sort(key=lambda s: list(map(int, s.split("."))), reverse=True)
return versions[0]


def download(cachedir, url, destination):
"""
Download the salt artifact from the given destination to the cache.
Expand Down

0 comments on commit d2c23de

Please sign in to comment.