Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(utils): wrong version checker #523

Merged
merged 3 commits into from
Jun 3, 2024
Merged
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
19 changes: 12 additions & 7 deletions kubespider/utils/version_parser.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
from typing import List, Tuple


def check_version_at_lest(current_version: str, target_version: str) -> bool:
if current_version == target_version:
return True
current_version = parse_version(current_version)
target_version = parse_version(target_version)
current_vers, current_n = parse_version(current_version)
target_vers, target_n= parse_version(target_version)
index = 0
while True:
if len(current_version) <= index or len(target_version) <= index:
while index < current_n and index < target_n:
if current_vers[index] < target_vers[index]:
return False
if current_version[index] > target_version[index]:
if current_vers[index] > target_vers[index]:
return True
index += 1
return current_n >= target_n


def parse_version(version_name: str) -> list[int]:
return [int(x) for x in version_name.split('.')]
def parse_version(version_name: str) -> Tuple[List[int], int]:
vers = [int(x) for x in version_name.split('.')]
return vers, len(vers)
Loading