Skip to content

Commit

Permalink
Use semver package
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Sharma <shubhash@microsoft.com>
  • Loading branch information
shubham1172 committed Jul 27, 2023
1 parent 42d8b15 commit f27fe0c
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from copy import deepcopy
from knack.log import get_logger
from knack.prompting import prompt, prompt_y_n
from packaging import version as packaging_version
from semver import VersionInfo

from ..vendored_sdks.models import Extension, PatchExtension, Scope, ScopeCluster
from .DefaultExtension import DefaultExtension
Expand Down Expand Up @@ -204,7 +204,7 @@ def _is_downgrade(v1: str, v2: str) -> bool:
Returns True if version v1 is less than version v2.
"""
try:
return packaging_version.Version(v1) < packaging_version.Version(v2)
except packaging_version.InvalidVersion:
return VersionInfo.parse(v1) < VersionInfo.parse(v2)
except ValueError:
logger.debug("Warning: Unable to compare versions %s and %s.", v1, v2)
return True # This will cause the apply-CRDs hook to be disabled, which is safe.

0 comments on commit f27fe0c

Please sign in to comment.