Skip to content

Commit

Permalink
have init use patch version not full version for gcp
Browse files Browse the repository at this point in the history
  • Loading branch information
dcmcand committed Nov 11, 2024
1 parent 41f5182 commit cbd2e0e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/_nebari/provider/cloud/google_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ def kubernetes_versions(region: str) -> List[str]:
return filter_by_highest_supported_k8s_version(supported_kubernetes_versions)


def get_patch_version(full_version: str) -> str:
return full_version.split("-")[0]


def get_minor_version(full_version: str) -> str:
patch_version = get_patch_version(full_version)
parts = patch_version.split(".")
return f"{parts[0]}.{parts[1]}"


def cluster_exists(cluster_name: str, region: str) -> bool:
"""Check if a GKE cluster exists."""
credentials, project_id = load_credentials()
Expand Down
6 changes: 4 additions & 2 deletions src/_nebari/subcommands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,15 @@ def check_cloud_provider_kubernetes_version(
versions = google_cloud.kubernetes_versions(region)

if not kubernetes_version or kubernetes_version == LATEST:
kubernetes_version = get_latest_kubernetes_version(versions)
kubernetes_version = google_cloud.get_patch_version(
get_latest_kubernetes_version(versions)
)
rich.print(
DEFAULT_KUBERNETES_VERSION_MSG.format(
kubernetes_version=kubernetes_version
)
)
if kubernetes_version not in versions:
if not any(v.startswith(kubernetes_version) for v in versions):
raise ValueError(
f"Invalid Kubernetes version `{kubernetes_version}`. Please refer to the GCP docs for a list of valid versions: {versions}"
)
Expand Down

0 comments on commit cbd2e0e

Please sign in to comment.