Skip to content
Merged
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0f79dfb
modified the projects and zones function
swastik959 Oct 22, 2023
3051574
[pre-commit.ci] Apply automatic pre-commit fixes
pre-commit-ci[bot] Oct 22, 2023
5d593b1
modified whole code
swastik959 Nov 3, 2023
53ca190
[pre-commit.ci] Apply automatic pre-commit fixes
pre-commit-ci[bot] Nov 3, 2023
2105e6e
Merge branch 'develop' into swastik
marcelovilla Jul 25, 2024
7d319b5
Fix google dependency versions
marcelovilla Jul 26, 2024
1088d94
Remove unused functions and fix calls to the Google Python APIs
marcelovilla Aug 2, 2024
a0694d1
Merge branch 'develop' into swastik
marcelovilla Aug 2, 2024
97677ec
[pre-commit.ci] Apply automatic pre-commit fixes
pre-commit-ci[bot] Aug 2, 2024
6f3d813
Add grpc-google-iam-v1
marcelovilla Aug 5, 2024
d6498f9
Merge branch 'swastik' of https://github.com/swastik959/nebari into s…
marcelovilla Aug 5, 2024
4daa377
Load credentials explictly from file and get project ID from environe…
marcelovilla Aug 5, 2024
ab7f216
Check if credentials are a file or not before reading them
marcelovilla Aug 5, 2024
4ac3911
Remove gcloud step
marcelovilla Aug 5, 2024
8a47dcd
Add google-auth as an explicit dependency
marcelovilla Aug 6, 2024
7be8fff
Use string ending instead of Path.isfile to check whether env var is …
marcelovilla Aug 6, 2024
bdddbe2
Fix dependency version specifier
marcelovilla Aug 6, 2024
6338899
Fix cleanup functions.
marcelovilla Aug 7, 2024
1c2fec3
Add explicit google auth scopes
marcelovilla Aug 9, 2024
d54739b
Merge branch 'develop' into swastik
marcelovilla Sep 4, 2024
88785a1
Merge branch 'develop' into swastik
marcelovilla Sep 5, 2024
f507f2d
Merge branch 'develop' into swastik
Adam-D-Lewis Sep 11, 2024
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
23 changes: 12 additions & 11 deletions src/_nebari/provider/cloud/google_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import subprocess
from typing import Dict, List

from google.cloud import compute, resourcemanager

from _nebari import constants
from _nebari.provider.cloud.commons import filter_by_highest_supported_k8s_version
from nebari import schema
Expand All @@ -22,22 +24,21 @@ def check_credentials():
def projects() -> Dict[str, str]:
"""Return a dict of available projects."""
check_credentials()
output = subprocess.check_output(
["gcloud", "projects", "list", "--format=json(name,projectId)"]
)
data = json.loads(output)
return {_["name"]: _["projectId"] for _ in data}
client = resourcemanager.Client()
projects = client.list_projects()
project_dict = {project.name: project.project_id for project in projects}

return project_dict


@functools.lru_cache()
def regions(project: str) -> Dict[str, str]:
"""Return a dict of available regions."""
check_credentials()
output = subprocess.check_output(
["gcloud", "compute", "regions", "list", "--project", project, "--format=json"]
)
data = json.loads(output.decode("utf-8"))
return {_["description"]: _["name"] for _ in data}
client = compute.Client()
regions = client.list_regions(project=project)
region_dict = {region.description: region.name for region in regions}

return region_dict


@functools.lru_cache()
Expand Down