Skip to content

Commit

Permalink
Cloud API: Use environment variable CRATEDB_CLOUD_ORGANIZATION_ID
Browse files Browse the repository at this point in the history
When not logged in using `croud login`, the "create project" operation
needs an organization identifier.
  • Loading branch information
amotl committed Nov 16, 2023
1 parent 78b2165 commit a9f4d82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cratedb_toolkit/cluster/croud.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def list_clusters(self):
wr = CroudWrapper(call=call)
return wr.invoke()

def create_project(self, name: str):
def create_project(self, name: str, organization_id: str = None):
"""
Create project.
Expand All @@ -74,10 +74,14 @@ def create_project(self, name: str):
from croud.__main__ import command_tree
from croud.projects.commands import project_create

# TODO: Refactor elsewhere.
organization_id = organization_id or os.environ.get("CRATEDB_CLOUD_ORGANIZATION_ID")

call = CroudCall(
fun=project_create,
specs=command_tree["projects"]["commands"]["create"]["extra_args"],
arguments=[
f"--org-id={organization_id}",
f"--name={name}",
],
)
Expand Down
1 change: 1 addition & 0 deletions tests/cluster/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def test_example_cloud_cluster_with_deploy(mocker, mock_cloud_cluster_deploy):
mocker.patch.dict(
"os.environ",
{
"CRATEDB_CLOUD_ORGANIZATION_ID": "4148156d-b842-4a86-8024-ecb380be1fc2",
"CRATEDB_CLOUD_SUBSCRIPTION_ID": "f33a2f55-17d1-4f21-8130-b6595d7c52db",
"CRATEDB_CLOUD_CLUSTER_NAME": "testcluster",
"CRATEDB_USERNAME": "crate",
Expand Down

0 comments on commit a9f4d82

Please sign in to comment.